Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: string manipulations.

by jwkrahn (Abbot)
on Nov 23, 2006 at 08:34 UTC ( [id://585685]=note: print w/replies, xml ) Need Help??


in reply to string manipulations.

Maybe you should be using a Hash of Arrays:
$ perl -le' my $str = "A: Gold, Black, Purple, Blue, Red B: Black, Neon Pink, +Neon Yellow, Neon Green, Neon Purple, Red, White, Neon Orange, Navy"; my %hash = map s/:// ? $_ : [ split /\s*,\s*/ ], grep length, split /\ +s*(\w+:)\s*/, $str; use Data::Dumper; print Dumper \%hash; ' $VAR1 = { 'A' => [ 'Gold', 'Black', 'Purple', 'Blue', 'Red' ], 'B' => [ 'Black', 'Neon Pink', 'Neon Yellow', 'Neon Green', 'Neon Purple', 'Red', 'White', 'Neon Orange', 'Navy' ] };

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (6)
As of 2024-04-19 11:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found