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

Re: text formatting in columns with hash?

by poj (Abbot)
on Jul 03, 2013 at 19:45 UTC ( [id://1042265]=note: print w/replies, xml ) Need Help??


in reply to text formatting in columns with hash?

Fill an array, use the value in col a as the column number and reset rows back to 0 when it changes

#!perl use strict; my @matrix=(); my $row = 0; my $prev_a; while (<DATA>){ chomp; my ($col_a,undef) = split(' ',$_,2); $row = 0 if ($col_a != $prev_a); $matrix[$row][$col_a] = $_; $prev_a = $col_a; ++$row; } for my $ar_row (@matrix){ print join " ",@$ar_row,"\n" } __DATA__ 0 0 d 0 1 d 0 1 d 0 2 d 0 2 d 1 0 d 1 0 d 1 1 d 1 2 d 1 2 d
poj

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (4)
As of 2024-04-19 05:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found