scooter wrote:
I want to load the value from scalar variable to a hash

Example:
my $a = "a, 1, b, 2, c, 3";

Now, I need to create a hash %b, which holds values like
%b = { a => 1, b => 2, c => 3 };

$ perl -le'
use Data::Dumper;
my $a = "a, 1, b, 2, c, 3";
my %b = $a =~ /[^, ]+/g;
print Dumper \%b;
'
$VAR1 = {
          'c' => '3',
          'a' => '1',
          'b' => '2'
        };


John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.                            -- Larry Wall

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to