Re: help slurping a file
- From: fxn@xxxxxxxxxxx (Xavier Noria)
- Date: Fri, 28 Oct 2005 16:47:10 +0200
On Oct 28, 2005, at 16:16, JupiterHost.Net wrote:
Hello,
My question is, why can't I slurp in the entire file?
Because you're fiddling with things that ought not be fiddled with ;p (IE $\)
instead:
use File::Slurp;
my @lines = read_file($file);
Wrong, that code assumes $file has the runtime platform conventions, which is not the case.
You'll end up with the entire file as a single string in @lines, not the expected array of lines. The reason is that \015 is the line separator in the file. Hence, seen as a text file in a Linux box it has only one line.
To make it work with File::Slurp that way we need to do precisely what you said we ought not to: fiddle with $/ before the call to read_file().
-- fxn
.
- Follow-Ups:
- Re: help slurping a file
- From: JupiterHost.Net
- Re: help slurping a file
- References:
- help slurping a file
- From: Renee Halbrook
- Re: help slurping a file
- From: JupiterHost.Net
- help slurping a file
- Prev by Date: Re: help slurping a file
- Next by Date: Re: How to put brackets in a string given substrings
- Previous by thread: Re: help slurping a file
- Next by thread: Re: help slurping a file
- Index(es):