vegasjoe has asked for the wisdom of the Perl Monks concerning the following question:
The string is setup like the following: Code,"data". The code is always numeric. The desired output is similiar to following:0,"104"1,"Assign Tracking Numb"29,"905745371116"526,"0201"99,""
The regex needs to be change to something else. /((\d*),"\w*")/gm;%rec = ( 0 => 104, 1 => 'Assign Tracking Numb', 29 => 905745371116, 526 => 0201, 99 => , );
$result = "0,\"104\"1,\"Assign Tracking Numb\"29,\"905745371116\"526,\ +"0201\"99,\"\""; %row = $result =~ /((\d*),"\w*")/gm; use Data::Dumper; print Dumper(%row); foreach $key (keys (%row) ) { print $key ."\n"; } Output (Not what I want) $VAR1 = '0,"104"'; $VAR2 = '0'; $VAR3 = '29,"905745371116"'; $VAR4 = '29'; $VAR5 = '526,"0201"'; $VAR6 = '526'; $VAR7 = '99,""'; $VAR8 = '99'; 0,"104" 29,"905745371116" 526,"0201" 99,""
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to Map Regex to Hash
by Roy Johnson (Monsignor) on Jun 30, 2006 at 21:04 UTC | |
by CountZero (Bishop) on Jun 30, 2006 at 21:34 UTC | |
|
Re: How to Map Regex to Hash
by japhy (Canon) on Jun 30, 2006 at 20:36 UTC | |
|
Re: How to Map Regex to Hash
by jwkrahn (Abbot) on Jun 30, 2006 at 20:36 UTC | |
|
Re: How to Map Regex to Hash
by TedPride (Priest) on Jul 01, 2006 at 01:05 UTC | |
by CountZero (Bishop) on Jul 01, 2006 at 08:10 UTC |