Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^5: cut vs split (suggestions)

by pijll (Beadle)
on Apr 17, 2005 at 07:54 UTC ( #448604=note: print w/ replies, xml ) Need Help??


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

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.


Comment on Re^5: cut vs split (suggestions)
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (8)
As of 2015-07-06 19:45 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 (81 votes), past polls