Ugh, best document the hell out of that. Split with parameters, splitting a tr - I see that everywhere... On Feb 9, 2014 6:45 PM, "Bill McCormick" <wpmccorm...@gmail.com> wrote:
> On 2/9/2014 10:48 AM, Bill McCormick wrote: > >> Trying to map the array list into a hash, but loose the double quotes >> surrounding the key's value. This is close, but it's not removing the >> quotes. >> >> Solutions? >> >> #!/usr/bin/perl -w >> use strict; >> use Data::Dumper; >> >> my @array = qw(foo1="bar1" foo2="bar2"); >> >> print "Array:\n"; >> print Dumper(@array); >> >> print "Hash:\n"; >> my %hash = map { split(/=/, $_, 2) } @array; >> >> print Dumper(%hash); >> >> >> Array: >> $VAR1 = 'foo1="bar1"'; >> $VAR2 = 'foo2="bar2"'; >> Hash: >> $VAR1 = 'foo2'; >> $VAR2 = '"bar2"'; >> $VAR3 = 'foo1'; >> $VAR4 = '"bar1"'; >> >> --- >> This email is free from viruses and malware because avast! Antivirus >> protection is active. >> http://www.avast.com >> >> >> >> Thanks for all the great ideas. I ended up finding another way before I > saw other replies: > > my %hash = map { split(/=/, tr/"//dr, 2) } @array; > > Anyway, I like the pure regexp method. Thanks Uri. > > -Bill > > --- > This email is free from viruses and malware because avast! Antivirus > protection is active. > http://www.avast.com > > > > -- > To unsubscribe, e-mail: beginners-unsubscr...@perl.org > For additional commands, e-mail: beginners-h...@perl.org > http://learn.perl.org/ > > >