in reply to Initializing an anonymous hash
Output:#!/usr/bin/perl -w use strict; my $hash = {'MONTH' => 'January'}; print $hash->{MONTH} . "\n"; my $string = q('MONTH' => 'January'); #from file # I split your original string, but there probably is a cleaner # way from your file read my @split = split / => /, $string; s/'//g for @split; print "@split\n"; my $hash1->{ $split[0] } = $split[1]; print $hash1->{MONTH} . "\n";
$ ./962633.pl January MONTH January January
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Initializing an anonymous hash
by Anonymous Monk on Mar 31, 2012 at 07:45 UTC |