Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
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 contemplating the Monastery: (5)
As of 2014-08-01 04:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (256 votes), past polls