in reply to Bitten by the lazy execution bug?
Wtf? If I comment out the print, it once again errors right off the bat saying the third column is null, and if I uncomment it again, it runs fine?
the $1..$3 aren't localized on entering a sub, therefore any sub that uses a regular expression somewhere *might* invalidate the references to the special regex capture variables, like:
... $_ = 'the small print'; if( /^\s*(\S+)\s+(\S+)\s+(.+\S)\s*$/ ) { sub1( 'replace into reference_code values (?,?,?)', $1, $2, $3 ) } sub sub1 { my $p0 = shift; # try to comment this line out and get your lesson print "looks like a statement somewhere\n" if $p0 =~ /\w+/; my ($p1, $p2, $p3) = @_; print "statement parameters: $p1, $p2, $p3\n"; } ...
Are you sure your program really did run without errors - only by inserting the "print" line?
BTW, interpolation of $1..$3 in the sub call (as has been suggested) also does the trick (by instantiating anonymous copies of $1..$3):
... sub1( 'replace into reference_code values (?,?,?)', "$1", "$2", "$3" +) ...
Regards
mwa
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Bitten by the lazy execution bug?
by mccready (Initiate) on Dec 08, 2007 at 20:38 UTC | |
by antirice (Priest) on Dec 09, 2007 at 06:56 UTC |