Discussion » "slurping"

This is a read-only copy. The forum ran on iamcal.com from 2000 until its database was lost in 2016, and this topic was rebuilt from copies saved by the Internet Archive's Wayback Machine. Some replies may be missing.
Posted by cal, 16:22, 18th March 2001:
 
slurping is the action of reading a whole file into memory. Since you say you want to "get the file into an array", this is slurping. Why do you need the file in an array?
Posted by brian, 16:22, 18th March 2001:
 
Is this bad?: (perl)$file = "data.dat" while (chomp($line = )) { push(@datalines, $line)
Posted by cal, 16:22, 18th March 2001:
 
exactly! something like:open(MYFILE,$file) or die $!MYFILE>
Posted by brian, 20:51, 18th March 2001:
 
Well that file is kind of like a database, each line has information in it:info||moreInfo||evenMoreInfoI am going to go through each line in the file and process it and print it out. (with a foreach loop). Now that I think about it, since I already have a while loop going through each line in the file, should I process the line in that loop so after its done with one line, the memory is erased for the next line?
Posted by brian, 02:29, 20th March 2001:
 
HEHE why didn't I think of that before. I am still learning, after writing in "Tribes Script" (www.tribes2.com), going back to perl was sort of hard :P Thanks :)
Posted by brian, 03:39, 21st March 2001:
 
OK this has been buging me forever. I have looked in lots of books and I cant figure this out. How to you send an email through perl.
Posted by cal, 08:32, 21st March 2001:
 
Either use backticks (or whatever) to execute sendmail (UINX) or use one of CPANs SMTP modules such as Net::SMTP
Posted by stallion, 20:33, 17th April 2001:
 
Brian, the above code will work in Perl, but you could always do the smart thing and use PHP's file function.One line, one function, all the slurp.http://www.php.net/file
Posted by brian, 00:21, 22nd April 2001:
 
I was thinking about learning PHP rather than perl, ill check it out. Thanks :)