FAQ
I wonder if anyone can help me with a question based more on curosity than a
desperate need to know. Say I have a data file with one key/value pair on
each line, which I want to read into a hash. I've been doing it in one of
two ways:

while (<>) {
($key, $value) = split;
$hash{$key} = $value;
}

or

push @array, split while <>;
%hash = @array;

What I'm wondering is if there is anything like:
push %hash, split while <>; # which doesn't work, or
%hash = split while <>; # but that overwrites all but the last pair.

Thanks

Mark C
--
------------------------------------------------------------------------
Dr Mark Crowe John Innes Centre
Norwich Research Park
Tel/Fax: +44 (1603) 450012 Colney
mailto:Mark.Crowe@bbsrc.ac.uk Norwich
NR4 7UH

Search Discussions

Discussion Posts

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 2 | next ›
Discussion Overview
groupbeginners @
categoriesperl
postedJun 19, '01 at 1:50p
activeJun 19, '01 at 2:08p
posts2
users2
websiteperl.org

People

Translate

site design / logo © 2022 Grokbase