mr.dunstan has asked for the wisdom of the Perl Monks concerning the following question:
I'm sure there's a better way, like reading the file into an array somehow. Oh perlmonks deliver me from this pain!!!!use strict, CGI, blah blah ... my $cgi = new CGI; my $filename = $cgi->param('uploaded_file'); my $file = $filename; # can't remember why I do this, alway +s have $file =~ s!^.*(\\|\/)!!; # something about cleaning stuff up my $buffer; my $content_to_parse; while (my $bytesread = read($filename,$buffer,1024)) { $content_to_parse = $content_to_parse . $buffer; } # ok now file contents are in $content_to_parse # try splitting on ^M (windoze newlines) my @contentarray = split /\015$/, $content_to_parse; # doesn't work - @contentarray is empty # scratch head, get another diet coke # now do line by line parsing ... the end
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: splitting on win32 linefeeds aka pass the crackpipe!
by little (Curate) on Feb 14, 2002 at 01:53 UTC | |
by mr.dunstan (Monk) on Feb 14, 2002 at 02:05 UTC | |
|
Re: splitting on win32 linefeeds aka pass the crackpipe!
by buckaduck (Chaplain) on Feb 14, 2002 at 02:25 UTC | |
by chipmunk (Parson) on Feb 14, 2002 at 04:05 UTC | |
by vek (Prior) on Feb 14, 2002 at 05:14 UTC |