Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Converting Column Into Row

by mickeyn (Priest)
on Jun 20, 2006 at 13:02 UTC ( #556382=note: print w/ replies, xml ) Need Help??


in reply to Converting Column Into Row

Hi,

A better way is to create a hash containing your arrays as values (I put your input into a file named 'test'):

use Data::Dumper; my %h; open FH, "test"; while (<FH>) { chomp; next if /^\s*$/; split /=/; push @{$h{$_[0]}}, $_[1]; } close FH; print Dumper \%h;
output:
$VAR1 = { 'A ' => [ ' 1', ' 2', ' 3' ], 'B ' => [ ' 5', ' 1', ' 7' ] };

Enjoy,
Mickey


Comment on Re: Converting Column Into Row
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (7)
As of 2015-07-02 05:34 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 (29 votes), past polls