Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!newstop!texsun!convex!news From: tchrist@convex.COM (Tom Christiansen) Newsgroups: comp.lang.perl Subject: Re: Reading a file into a string Message-ID: <1991Jan30.005821.13013@convex.com> Date: 30 Jan 91 00:58:21 GMT References: <5231@taux01.nsc.com> Sender: news@convex.com (news access account) Reply-To: tchrist@convex.COM (Tom Christiansen) Organization: CONVEX Software Development, Richardson, TX Lines: 22 Nntp-Posting-Host: pixel.convex.com From the keyboard of avi@taux01.nsc.com (Avi Bloch): :How do I read an entire file into a string other than the obvious way of :reading it line by line and concatenating it. I answered in mail, but for the record: 1) $foo = `cat $file`; 2) open (FILE, $file); undef $/; $foo = ; close(FILE); The cat method costs a bit more, but both are more costly than iterating over the file a line at a time. --tom -- "Hey, did you hear Stallman has replaced /vmunix with /vmunix.el? Now he can finally have the whole O/S built-in to his editor like he always wanted!" --me (Tom Christiansen )