[33057] in Perl-Users-Digest
Perl-Users Digest, Issue: 4333 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Dec 21 14:09:13 2014
Date: Sun, 21 Dec 2014 11:09:02 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sun, 21 Dec 2014 Volume: 11 Number: 4333
Today's topics:
Read and place lines in key/value list <tuxedo@mailinator.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 21 Dec 2014 19:26:05 +0100
From: Tuxedo <tuxedo@mailinator.com>
Subject: Read and place lines in key/value list
Message-Id: <m773bu$ttu$1@news.albasani.net>
Hello,
I have a text file with lines:
key1 value1
key2 value two
key3
What is a good way to import this into a list, so it would be the same as:
%list = ('key1' => 'value1',
'key2' => 'value two'
'key3' => '');
Each line of the text file represents a key and optional value.
The separator is the first whitespace on each line.
In case there is more than one whitespace on a line, as on line 2, the
first boundary is the key while the remaining parts is the value for the
key. Or in case there is only a key, as on line 3, it's value becomes empty.
Many thanks,
Tuxedo
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V11 Issue 4333
***************************************