;
my $age = $1 if ($_ = <>) =~ /AGE\s+(.*)$/;
my $book = $1 if ($_ = <>) =~ /Book\s+(.*)$/;
$hash{$name}->{age} = $age;
$hash{$name}->{book} = $book;
}
}
# then print the value
-Original Message-
From: anand kumar
Sent: Feb 15, 2006 10:33 PM
To: beginners@perl.org
Su
= <>) =~ /Book\s+(.*)$/;
$hash{$name}->{age} = $age;
$hash{$name}->{book} = $book;
}
}
# then print the value
-Original Message-
From: anand kumar <[EMAIL PROTECTED]>
Sent: Feb 15, 2006 10:33 PM
To: beginners@perl.org
Subject: Re: hash array
Hi ,
On 2/15/06, anand kumar <[EMAIL PROTECTED]> wrote:
> can anyone help me on how to store the data with hash key as the 'Name'
> and the hash strings as the details of 'AGE' and 'Book'
Perl's hashes use a single key to look up a single value. So, to keep
this simple, you can use two hashes, %age
Hi ,
Thanks for the reply. but can u help me out if the data is large and need a
loop to store(also if possible give instructions if the record has variable or
optional number of fields).
Jeff Pang <[EMAIL PROTECTED]> wrote:
Name ABC
AGE 25
Book perl
Name DEF
AGE 20
Book linux
Name GHI
Name ABC
AGE 25
Book perl
Name DEF
AGE 20
Book linux
Name GHI
AGE 21
Book PHP
.
can anyone help me on how to store the data with hash key as the 'Name' and
the hash strings as the details of 'AGE' and 'Book'
Hello,I think you could do it as followin
just dereference it:
foo( @{ $R{"first"} } );
it's as easy as that =)
hth
Jos Boumans
>
> Hi all,
>
> here's my question :):
>
> I define a hash array:
> our %R=("first" => [ "one", "two" ], "second" => ["third", "fourth"]);
>
> Now I can get back back array references from this using: