>>>>> "SHC" == Shawn H Corey <[email protected]> writes:
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/, <IN>);
>> @header{"info"} = split(/\t\n/, <IN>);
SHC> I'm not sure but I think this is what you want:
SHC> ( $header{"keys"}, $header{"info"} ) = split(/\t\n/, <IN>);
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/, <IN>);
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: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/