Kevin Walker on Wed, 2 May 2001 14:00:48 -0400


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: Quick question: how to slurp a file?


what's wrong with <>?

You just need to undefine the record seperator $/


$/ = "";
open F,"myfile.txt" || die "$!";
$filecontents = <F>;

a la the camel 

Alternatively, you could do it with sysread ...

KMW


> We're beating our heads against a wall here. The office mate swears perl
> has a way to read in an entire file in one gulp (as opposed to the more
> familiar <> operator). 
> 
> Can anyone confirm or deny?
> 
> Thanks!
> -------------------------------------------------------------------------
> Susan J. Talbutt				      talbutt@sabresys.com
> Sabre Systems, Inc.					  www.sabresys.com
> -------------------------------------------------------------------------
> **Majordomo list services provided by PANIX <URL:http://www.panix.com>**
> **To Unsubscribe, send "unsubscribe phl" to majordomo@lists.pm.org**


**Majordomo list services provided by PANIX <URL:http://www.panix.com>**
**To Unsubscribe, send "unsubscribe phl" to majordomo@lists.pm.org**