Scope of variables in a function

Marcel Grünauer hanekomu at gmail.com
Sat Jun 1 18:03:45 BST 2013


On H.25/06/01, at 18:43, Andrew Beverley <andy at andybev.com> wrote:

>  my $result = "FOO" if $in =~ /foo/;

Conditional variable declaration is confusing.

Try:

    my $result;
    $result = "FOO" if $in =~ /foo/;

See https://metacpan.org/module/Perl::Critic::Policy::Variables::ProhibitConditionalDeclarations

Marcel




More information about the london.pm mailing list