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.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 11-16-2002, 08:50 PM   #1
kenny
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?
kenny is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-16-2002, 10:31 PM   #2
some_idiot
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= &lt WORDLIST&gt ;
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!
some_idiot is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.