http://qs321.pair.com?node_id=1181658


in reply to Code Issue after Upgrading the perl from 5.14.4 to 5.22.3

Hi,
please use below in your code first
use strict; use warnings;
Also it looks like $mapattach variable is not declared with the right scope and causing the issue or data in the input file gets change for different runs.

Replies are listed 'Best First'.
Re^2: Code Issue after Upgrading the perl from 5.14.4 to 5.22.3
by stevieb (Canon) on Feb 10, 2017 at 15:36 UTC

    It is in the correct scope the way it is being used (global in this case), it's just difficult to tell because of poor code formatting. It should all be left-justified, with the exception of the statements within the while and unless statements, which should be indented only once.

    Perl::Tidy can help those who are unfamiliar with proper indentation get a good grasp of it.

    my %CONFIG_PARAMS; my $mapattach; while (my ($key , $value) = each(%CONFIG_PARAMS)) { if ($file =~ /$key/) { $mapattach = $value; } } unless (defined $mapattach) { Println "WARN : Ignoring $file, not found in the config file"; }

    What I see is that %CONFIG_PARAMS has been declared, but not defined, so it'll always be empty. However, perhaps this isn't the real code OP is really using, which makes troubleshooting the issue pretty much impossible.

Re^2: Code Issue after Upgrading the perl from 5.14.4 to 5.22.3
by Anonymous Monk on Feb 10, 2017 at 15:21 UTC
    Also it looks like $mapattach variable is not declared with the right scope

    Which scope instead?