|
|
|
Your skill will accomplish what the force of many cannot |
|
| PerlMonks |
Re: Re: Perl Idioms Explained - my $string = do { local $/; <FILEHANDLE> };by antirice (Priest) |
| on Aug 29, 2003 at 20:31 UTC ( #287827=note: print w/ replies, xml ) | Need Help?? |
|
Otherwise you can't really distinguish between lines. Next, you're having perl read the file in, split the file on $/, and then rejoin everything and you end up with a string that was exactly what it was before the split. If you just localize $/ and then read the file in, you're done. Of course, I have some nice benchmarks that show the local $/ method to be a little under 5 times faster. As with any other benchmarks, YMMV.
Update: As chromatic has pointed out, I'm a twit. Hope this helps. antirice
In Section
Meditations
|
|
||||||||||||||||||||||