I have a perl file that has this,
########################PerlFile.pl########################################################### #!/usr/bin/perl
while(<>){ chomp; if(/\s*\$[a-z]\w+\s*/i){ # if(/\b\$[a-z]\w+\b/i){ print "Matched: $` -- $& -- $' :\n"; }
else{ print "No match:$_\n"; }
} ################################################################################################
I have another file that has this in it,
############################testfile.txt########################################################### $he1lo is the name of a variable what is not allowed $0 is this but this is $a123wgfd343w cool this is correct though $hello dont know why didnt work before. I sure hope this doesnt pass alf$f12w32 cuz it shouldnt $alfonso does match though $hello ##########################################################################################
The perl code is basically supposed to look for real possible scalar variable names. So there should only be two failures,
the second and fifth line should not pass.
Now, if I run the program how it is, I get this,
############################answer1.txt#################################################
Matched: -- $he1lo -- is the name of a variable :
No match:what is not allowed $0 is this
Matched: but this is -- $a123wgfd343w -- cool :
Matched: this is correct though -- $hello -- dont know why didnt work before. :
Matched: I sure hope this doesnt pass alf -- $f12w32 -- cuz it shouldnt :
Matched: -- $alfonso -- does match though :
Matched: -- $hello -- :
No match:
##########################################################################################
if i run it with the commented section as the if statement, and the current if statement commented out, i get this,
###############################answer2.txt################################################## No match:$he1lo is the name of a variable No match:what is not allowed $0 is this No match:but this is $a123wgfd343w cool No match:this is correct though $hello dont know why didnt work before. Matched: I sure hope this doesnt pass alf -- $f12w32 -- cuz it shouldnt : No match:$alfonso does match though No match:$hello No match: ###########################################################################################
With regard to answer2.txt, why doesn't it match lines 1,3,4,5 and 6? In the camel book(pg40), it says that the word bound \b matches the beginning of lines.
Any advice would be appreciated.
Thanks.
_______________________________________________ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs