Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re: What would be the easier way

by CountZero (Bishop)
on Mar 04, 2013 at 02:17 UTC ( #1021564=note: print w/replies, xml ) Need Help??

in reply to What would be the easier way

I would do it this way:
use Modern::Perl; use Data::Dump qw/dump/; my %heights; while (<DATA>) { push @{$heights{$1}}, $3 if /set\s+height\s+"([^"]+)"\s*("([^"]+)" +)?/; } say dump(%heights); __DATA__ set height "house" set height "house" "5 meter" set height "house" "10 yards" set height "table" "80 cm" set height "table" "30 inch"
( "house", [undef, "5 meter", "10 yards"], "table", ["80 cm", "30 inch"], )


A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

My blog: Imperial Deltronics

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (8)
As of 2016-10-25 07:49 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (315 votes). Check out past polls.