Re: Load hash from a scalar

2008-03-31 Thread John W. Krahn
sanket vaidya wrote: From: scooter [mailto:[EMAIL PROTECTED] 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 }; Here is the code to accomplish your task. u

RE: Load hash from a scalar

2008-03-30 Thread sanket vaidya
rint "$_ => $b{$_}\n"; } The output is: c => 3 a => 1 b => 2 Hope it is useful. -Original Message- From: scooter [mailto:[EMAIL PROTECTED] Sent: Friday, March 28, 2008 12:00 PM To: beginners@perl.org Subject: Load hash from a scalar I want to load the value fro

Re: Load hash from a scalar

2008-03-28 Thread John W. Krahn
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

Load hash from a scalar

2008-03-28 Thread scooter
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 }; TIA. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://le