FAQ

On 2014-02-09 17:48, Bill McCormick wrote:

Trying to map the array list into a hash, but loose the double quotes
surrounding the key's value.
Or do str-to-hash:

perl -Mstrict -MData::Dumper -wE'

    my $str = q(foo1="bar1" foo2="bar2");

    my $re_kv = qr/\s*(\S+)\s*=\s*"([^"]*)"/;

    my %hash = $str =~ /$re_kv/g;

    say Dumper(\%hash);
'

$VAR1 = {
            'foo1' => 'bar1',
            'foo2' => 'bar2'
          };

--
Ruud

Search Discussions

Discussion Posts

Previous

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 9 of 9 | next ›
Discussion Overview
groupbeginners @
categoriesperl
postedFeb 9, '14 at 9:25p
activeFeb 10, '14 at 11:52a
posts9
users6
websiteperl.org

People

Translate

site design / logo © 2021 Grokbase