oops I've maybe got the post right this time I'm a bit messed up with $_ The code below failed to work til I was specific as what to write. In the IF block "print NEW;" worked but in the ELSE block it failed, but once I explicitly used $fields[0] it was fine. $_ has me a bit frustrated with loops in loops as to which $_ I'm using. Regards Ian.
while (<UNMATCHED>) { @fields = split(/:/, $_); $wd = substr($fields[0], 0, 1); if($wd eq "/") { my $rtn = search ($fields[0], UNUSED); #Returns 1 i +f #fields[0] is found in UNUSED. print "Return is = $rtn \n"; if($rtn == 1) { print "Writing to CHANGED. \n"; print CHANGED "$fields[0] \n"; # print NEW; #This works in IF but n +ot in ELSE ? } else { print "Writing to NEW \n"; print NEW "$fields[0] \n"; #This works # print NEW; #This does not } } }
In reply to $_ confusion with loops in loops by stanley82
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |