Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^3: Split output by tabs

by shmem (Canon)
on Nov 13, 2012 at 09:41 UTC ( #1003576=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Split output by tabs
in thread Split output by tabs

is there a way of specifying certain columns to be printed? e.g the 10th,18th and 20th column?

One way to do it - use an array slice:

{ local $" = "\t"; print $OUT map "@{$_}[10,18,20]\n", sort { $a->[10] cmp $b->[10] } @ +out; }

See References quick reference.


Comment on Re^3: Split output by tabs
Download Code
Re^4: Split output by tabs
by perlnoobster (Sexton) on Nov 13, 2012 at 09:52 UTC
    wow that is perfect, where can i read up on in regards to skipping blank/empty values when splitting arrays? :)
      where can i read up on in regards to skipping blank/empty values when splitting arrays?

      Something is wrong wrt your question, since you don't split arrays, you slice or join them. Do you mean omitting empty fields splitting a record, or omitting empty/undefined array elements joining an array?

        Sorry I meant, the original file (orders) has blank values in some columns, i'd like for them to be omitted from the results (orders_today.txt) i.e not printed, is that possible?

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (13)
As of 2015-07-01 16:29 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 (11 votes), past polls