finddata has asked for the wisdom of the Perl Monks concerning the following question:

Here am trying to match the files using perl?
if ( ( -d $name ) && ( exists $name_map->{$name} ) ) { #print $name; my $new_name = $name_map->{$name}; # print $new_name; rename_file_or_dir( $name, $new_name ); $name = $new_name; #print $name; } elsif ( -f $name ) { if (( my $base_name = $name) =~ s/\.config$// ) { if ( $name_map->{$base_name} ) { my $new_name = $name_map->{$base_name} . '.config' +; # print $new_name; rename_file_or_dir( $name, $new_name ); change_file( $mapfile, $name_map, $regex ); }
the above print $new_name fails to print the statement .

Replies are listed 'Best First'.
Re: following if condition fails to print its variable using perl?
by hippo (Archbishop) on Mar 15, 2017 at 09:16 UTC

    You've posed a substantial number of very related questions recently. If you'd like some help to solve a particular problem which you have encountered with Perl then you will receive a great deal more help if you read, understand and put into practice the suggestions of SSCCE.

    The choice is entirely yours of course. However, if you continue in the same vein as currently you may find that both the patience and the interest of other monks will wain.

Re: following if condition fails to print its variable using perl?
by stevieb (Canon) on Mar 15, 2017 at 04:32 UTC

    Please show us what your input is, as well as what your expected output is.

    Being thrown a block of code without any context makes it a bit difficult to understand what you need.

    A reply falls below the community's threshold of quality. You may see it by logging in.