Re: chomp hash keys?
- From: Tad McClellan <tadmc@xxxxxxxxxxxxxx>
- Date: Fri, 28 Apr 2006 22:08:22 -0500
usenet@xxxxxxxxxxxxxxx <usenet@xxxxxxxxxxxxxxx> wrote:
According to perldoc -f chomp:
>> If VARIABLE is a hash, it chomps the hash's values, but not its
keys.
Is there an easy way to "overcome" this?
You can't change a key in the context of a hash, because the
key is the index.
You can create a new element with a newlineless key and delete
the element with the newlined key.
chomp (my %person = (<DATA>));
The keys, of course, have linefeeds on the end, which I do not want.
What is the best way to populate my hash with linefeed-ed data?
my %person = map {chomp; $_} <DATA>;
--
Tad McClellan SGML consulting
tadmc@xxxxxxxxxxxxxx Perl programming
Fort Worth, Texas
.
- References:
- chomp hash keys?
- From: usenet
- chomp hash keys?
- Prev by Date: software help for a hardware guy..
- Next by Date: Re: open() function quesiton
- Previous by thread: Re: chomp hash keys?
- Next by thread: Re: chomp hash keys?
- Index(es):