Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Parsing lines containing extra carriage returns

by jeroenes (Priest)
on Jun 13, 2001 at 09:34 UTC ( #88012=note: print w/replies, xml ) Need Help??


in reply to Parsing lines containing extra carriage returns

If bikeNomad's solution doesn't work, just split the whole thing on tabs (untested):
my $file; { local $/ = undef; # learned something ;} $file = <>; #or <FILE> } $file =~ tr/\r//d; #remove carriages my @items = split /[\t\n]/, $file; #one array of items; my $rowsize = 3; my @AoA; while( @items >= $rowsize ){ push @AoA, [splice @items, 0, $rowsize]; }
.... this works only if you're garanteed to have 3 columns.

Hope this helps,

Jeroen
"We are not alone"(FZ)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://88012]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (8)
As of 2017-08-23 18:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Who is your favorite scientist and why?



























    Results (355 votes). Check out past polls.

    Notices?