Re: first post
am 21.07.2011 06:52:03 von Uri Guttman>>>>> "SHC" == Shawn H Corey
SHC> On 11-07-20 10:28 PM, H Kern wrote:
>> use strict;
>> use warnings;
>> my %header;
>>
>> open( IN, "<", $ARGV[0] );
>>
>> @header{"keys"} = split(/\t\n/,
>> @header{"info"} = split(/\t\n/,
SHC> I'm not sure but I think this is what you want:
SHC> ( $header{"keys"}, $header{"info"} ) = split(/\t\n/,
nope. he is splitting two different input lines and you read in one
line.
what perl is saying is that @header{'keys'} is a literal single index in
a slice which is just wrong. a slice needs multiple keys or an array for
the index and then perl thinks it is fine.
the next problem is that $header{'keys'} is a scalar value now and split
expects to be assigned to a list. so the solution is to make a list:
( $header{"keys"} ) = split(/\t\n/,
that way perl keeps quiet as the index and sigil are in agreement. the
() make a list so only the first value of the split will be assigned to
the hash element. everyone is happy!
uri
--
Uri Guttman -- uri AT perlhunter DOT com --- http://www.perlhunter.com --
------------ Perl Developer Recruiting and Placement Services -------------
----- Perl Code Review, Architecture, Development, Training, Support -------
--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/