![]() |
![]() |
![]() |
||||
Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us. |
![]() ![]() |
|
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. |
|
Thread Tools |
![]() |
#1 |
Confirmed User
Industry Role:
Join Date: Mar 2002
Posts: 7,245
|
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?
![]() |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#2 |
Confirmed User
Join Date: May 2002
Location: Doesn't matter, I'm not buying you another pint!
Posts: 1,511
|
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! |
![]() |
![]() ![]() ![]() ![]() ![]() |