Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: arrange output in columns

by space_monk (Chaplain)
on Jun 18, 2013 at 12:22 UTC ( #1039556=note: print w/replies, xml ) Need Help??


in reply to arrange output in columns

Update:Working version :-)

It's a slow day....
use strict; use warnings; use English; # let's talk like pirates.... my @arr; my $fc = 0; for my $file (@ARGV) { open my $fh, "<$file" or die "We're screwed with $file"; while (<$fh>) { chomp; # maybe s/\s+$// ? $arr[$INPUT_LINE_NUMBER][$fc] = $_; } close $fh; $fc++; # inc filecount } # print for (my $i =1; $i <= $#arr; $i++) { # fill in the blanks print join(',', map { $arr[$i][$_] // '' } 0..$fc-1)."\n"; }
If you spot any bugs in my solutions, it's because I've deliberately left them in as an exercise for the reader! :-)

Replies are listed 'Best First'.
Re^2: arrange output in columns
by poj (Parson) on Jun 18, 2013 at 14:39 UTC
    "I might get the bugs out of this later.... "

    Here's the 3 missing characters you'll need to fix the script  = { }

    but even when fixed it doesn't give the required result for files with different record counts.

    Output Required a,2 a,2 b,f b,f c,4 c,4 s ,s w ,w
    poj
      Thanks for the input. I knocked this up in part of my lunchbreak while munching a burrito, and it was totally untested. :-)

      Update: I spotted the problems you mentioned before you posted and they've now been fixed.

      Anyway, as my footer says, it's polite to ensure that the reader still has to think through some of the issues, especially as this may be a homework assignment! :-)

      If you spot any bugs in my solutions, it's because I've deliberately left them in as an exercise for the reader! :-)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1039556]
help
Chatterbox?
[perldigious]: Snowshoeing time stevieb? I need to buy a pair so I can walk my German Shepherd properly through the country.
[stevieb]: yeah, I snowshoe a fair amount in the mountains. I also use spikes similar to these very often as well
[perldigious]: Discipulus: alternate link
[stevieb]: LOL you can easily replace "Helsinki" with "Alberta"
[perldigious]: I used to live at the top of a very steep hill stevieb, I can relate to the video. Literally used to have to build up momentum and try to force my vehicle to make it up the hill to park in my driveway properly... didn't always make it.
[choroba]: Why don't they use tire chains?
[perldigious]: First snow, probably not prepared right away choroba.
[stevieb]: it's Quebec... they do weird stuff there :) In the mountains, it is *mandatory* for trucks to use tire chains. Many passenger vehicles do as well (but it's not mandatory for them)
[perldigious]: That stuff can hit fast... like what we just got where I'm at. Saw a few people who had slid OUT of the roundabout I have to drive through to get to work, not used to the ice yet, take awhile to get the hang of it again and make vehicle adjustments.
[stevieb]: man, when the roads are glare ice, I don't even bother going to work or out... unless I absolutely have to, or was already out in the first place

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (10)
As of 2016-12-06 16:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (112 votes). Check out past polls.