in reply to Re: splitting directly to hash
in thread splitting directly to hash

Not quite (for the values being blank):

#!/usr/bin/perl my $env = "1 2 3 4 5"; my %h = split //, $env; use Data::Dumper; print Dumper \%h;

Output:

$VAR1 = { '4' => ' ', '1' => ' ', '3' => ' ', '2' => ' ', '5' => undef };


--chargrill
s**lil*; $*=join'',sort split q**; s;.*;grr; &&s+(.(.)).+$2$1+; $; = qq-$_-;s,.*,ahc,;$,.=chop for split q,,,reverse;print for($,,$;,$*,$/)

Replies are listed 'Best First'.
Re^3: splitting directly to hash
by Cabrion (Friar) on Nov 22, 2006 at 01:08 UTC
    OK, but just append a space before you split.

    my $env = "1 2 3 4 5".' '; my %h = split //, $env;

    Also, this assumes the poster meant:  key =>' ' and not key => '' when the they said "blank".