It looks like i had a scope problem a little further up in the code. the only reason i noticed it was because i attempted to run your code with the addition on an undelcared var. i.e.
#!/usr/bin/perl use strict; use warnings; my $foo = undef; # No warning my $line = 'substitute for $foo in $bar here'; $line =~ s/(\$\w+)/"defined $1 ? $1 : ''"/eeg; print $line, "\n";
hairbear% ./test2.pl Use of uninitialized value in substitution iterator at ./test2.pl line + 11. substitute for in here
Edit by tye: remove PRE tags around long lines
In reply to Re^4: Use of uninitialized value in substitution iterator in variable expansion
by jaco
in thread Use of uninitialized value in substitution iterator in variable expansion
by jaco
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |