in reply to Use of uninitialized value $var in pattern match (m//)

The code you have posted does not produce that warning.

$ perl -w my $funct = sub($) { my $var = shift; my $var2 = $var =~ /red|green|blue/; $var2 = 'magenta' if ($var eq 'm'); return $var2; }; $

Replies are listed 'Best First'.
Re^2: Use of uninitialized value $var in pattern match (m//)
by Laurent_R (Canon) on Apr 10, 2015 at 17:10 UTC
    Just compiling the sub ref will not produce that warning anyway. The sub ref needs to be actually called by some other code and executed to get an unitialized value warning.

    Je suis Charlie.