help slurping a file
- From: reneeh@xxxxxxxxxxxx (Renee Halbrook)
- Date: Fri, 28 Oct 2005 02:15:08 -0700
Hi,
I'm not sure if this is the correct group to post this question to. If there
is a better forum for this kind of question, please let me know.
I am trying to slurp a file that was written on Mac OSX, using a standard
text editor.
I am developing on a windows machine, and running my scripts on a Linux box.
I get the same problem on both machines.
If I set the local($\ = "\r")
I can get a line by line read of the file.
However, if I set the
local($\=undef)
or
local($\="")
The script will only read in the first line of the file, and then quit.
I got a read of the byte code in java, and the endline character is indeed
"\r".
My question is, why can't I slurp in the entire file?
Below is a sample of my code:
#!/usr/local/bin/perl
use warnings;
my $file = "pathnameofmyfile";
open( MYFILE, "$file" ) or die "Can't open $file for reading: $!\n";
readfile();
close(MYFILE);
sub readfile(){
local($/) = "\r";
while ( my $line = <MYFILE> ){
print "line is $line\n";
}
}
Renee Halbrook
Bioinformatics Programmer
The Carnegie Institution of Washington
Department of Plant Biology
260 Panama Street
Stanford, CA 94305
.
- Follow-Ups:
- Re: help slurping a file
- From: JupiterHost.Net
- Re: help slurping a file
- From: John W. Krahn
- Re: help slurping a file
- Prev by Date: Re: Die without textoutput?
- Next by Date: Re: Die without textoutput?
- Previous by thread: Die without textoutput?
- Next by thread: Re: help slurping a file
- Index(es):
Relevant Pages
|