Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^2: need help to print some lines

by Anonymous Monk
on Nov 29, 2012 at 00:41 UTC ( #1006135=note: print w/ replies, xml ) Need Help??


in reply to Re: need help to print some lines
in thread need help to print some lines

without taking anything away from toolic beautiful solution, one can also still write this:

use warnings; use strict; my $array_organizer = [ [], [] ]; while (<DATA>) { push @{ $array_organizer->[0] }, [split]->[0]; push @{ $array_organizer->[1] }, [split]->[1]; } for my $value ( @{$array_organizer} ) { print map { $_ } @{$value}, $/; } __DATA__ a f b g c h d i e j


Comment on Re^2: need help to print some lines
Download Code
Re^3: need help to print some lines
by 2teez (Priest) on Nov 29, 2012 at 00:57 UTC

    Instead of repeating push function, why not:

    ... while (<DATA>) { for my $index ( 0 .. 1 ) { push @{ $array_organizer->[$index] }, [split]->[$index]; } } ...

    If you tell me, I'll forget.
    If you show me, I'll remember.
    if you involve me, I'll understand.
    --- Author unknown to me

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (11)
As of 2015-07-06 18:03 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 (80 votes), past polls