gives the line number of the line with the shift command.
I'm not sure what would cause that, but the warning is indeed originating from "$item". $item contains undef, either because the first element of @data was undef before the shift, or because @data was empty before the shift.
By the way, shifting out of @data will not effect @{$hoa{$head}}. You need to shift from @{$hoa{$head}} directly to do that.
$\ = "\n"; { my %hoa = ( head => [ 'abc', 'def' ] ); print shift(@{$hoa{head}}); # abc print @{$hoa{head}}; # def -> ok } { my %hoa = ( head => [ 'abc', 'def' ] ); my $data = $hoa{head}; print shift(@$data); # abc print @{$hoa{head}}; # def -> ok } { my %hoa = ( head => [ 'abc', 'def' ] ); my @data = @{$hoa{head}}; print shift(@data); # abc print @{$hoa{head}}; # abcdef -> BAD! }
In reply to Re: Hash of arrays.. can't shift on derefferenced array
by ikegami
in thread Hash of arrays.. can't shift on derefferenced array
by esddew
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |