in reply to Re: Error Unitialized value and use
in thread Error Unitialized value and use
... annotation and dna variables are declared as a list and are assigned the values of match variables 1 and 2 after a successful match.
Note that it's also possible to "capture the captures" to lexicals and die on match failure in a single statement:
I prefer this practice because it's all too possible, believe me, to insert just one more pattern match test between the original capturing statement and the separate statement intended to assign its capture variables $1 $2 ... to lexicals, in which case the original capture groups sometimes, but not always, and perhaps quite silently (gotta love this bug!), become invalid.c:\@Work\Perl\monks>perl -wMstrict -le "for my $record (qw(eks---wye eks---wyyye)) { my ($x, $y) = $record =~ m{ \A (eks) .* (wye) \z }xms or die qq{malformed record '$record'}; ;; print qq{record '$record': got '$x' '$y'}; } " record 'eks---wye': got 'eks' 'wye' malformed record 'eks---wyyye' at -e line 1.
Give a man a fish: <%-{-{-{-<
|
|---|