![]() |
perl file handles
I enjoy learning perl in my spare time and I am having a hard time trying to figure out how to open a file and match each line agaisnt a $variable. For example if the variable was a name and the file contained 500 names and I wanted to see if the variable name matched any in the file. Anyone know what I talking about?
:helpme |
What something like....
$VARIABLE1 = "SOMETEST"; open (WORDLIST, "wordlist.txt"); @RAWWORDS= < WORDLIST> ; close (WORDLIST); foreach $LINE (@RAWWORDS) { chop $LINE; if ($LINE = $VARIABLE1) { print "Match with $LINE \n"; } } F'ing display parser on the board! Take the spacing out on the less than symbol on the 3rd line where we dump the contents of a file into the array. 500 lines for an array isn't bad, don't do this method for 10000+ lines unless you've got some time to waste. I'm tired and I've fought with the parser, milage may vary! This should be what you want for a quick and dirty. If it doesn't work check the web from here. Cheers! |
All times are GMT -7. The time now is 07:42 AM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123