Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
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)


Comment on Re: Parsing lines containing extra carriage returns
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://88012]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (8)
As of 2015-07-04 15:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (60 votes), past polls