Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Why? uninitialized value in pattern match when using if (defined)

by SamCG (Hermit)
on Mar 22, 2006 at 00:08 UTC ( [id://538354] : note . print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    use warnings;## good line to have.  use strict; is also prudent
    $x=undef;    ## I explicitly set it to undef here]
    ...
    
    ($s)=$x=~m/regex/; ## $x is undefined, and produces warning
    print $s;          ## presumably, I wanted $s for something