
Keep It Simple, Stupid

Re^4: cut vs split (suggestions)

by sk (Curate)
on Apr 17, 2005 at 07:01 UTC ( #448601=note: print w/ replies, xml ) Need Help??

in reply to Re^3: cut vs split (suggestions)
in thread cut vs split (suggestions)

Very interesting! Thanks for the new idea!


update: corrected <> with $_ per pijll post

this finishes in about 14 seconds.... corrected timing

this takes about 18 seconds



My laptop is 1.6G Centrino/1GB Ram/perl, v5.6.1



Comment on Re^4: cut vs split (suggestions)
Select or Download Code
Re^5: cut vs split (suggestions)
by pijll (Beadle) on Apr 17, 2005 at 07:54 UTC
    You are using both the -n switch and <> in the first line! This means you lose half of your lines...

    Anyway: -n does an unnecessary chomp on every line, so remove that; and use a limit on split: it doesn't actually need to split all 25 fields:

    perl -le 'BEGIN{$,=","} print+(split",",$_,16)[0..14]for <>' numbers.c +sv
    Update: But for<> reads all lines in at ones; you may not want that with large files, so use while <> instead.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (11)
As of 2014-03-14 11:24 GMT
Find Nodes?
    Voting Booth?

    Have you used a cryptocurrency?

    Results (303 votes), past polls