in reply to Re^2: capture value from two patterns (updated)
in thread capture value from two patterns
so always check before accessing it
for (qw(a X b)) { my $id = $1 if /(a)/ or /(b)/; print qq{'$_' -> '$id'\n}; }
C:/Perl_524/bin\perl.exe -w d:/exp/pm_or_regex.pl Use of uninitialized value $id in concatenation (.) or string at d:/ex +p/pm_or_regex.pl line 5. 'a' -> 'a' 'X' -> '' 'b' -> 'b'
I kept the warning in intentionally.
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
|
---|