Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re: Hash of arrays.. can't shift on derefferenced array

by Eimi Metamorphoumai (Deacon)
on Mar 28, 2007 at 14:55 UTC ( #607039=note: print w/replies, xml ) Need Help??

in reply to Hash of arrays.. can't shift on derefferenced array

Are you sure you're actually getting the result you think you're getting? Specifically, it really sounds like the line number should correspond to your print "$item"; line. And "Use of uninitialized value in string at..." is a warning, not an error (unless you're doing something strange). I'd suggest that you look at what exactly is in your hoa before the loop. Here's test code that works just fine.
#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my %hoa = ( a => ["apple", "aardvark"], b => ["banana", "bandana"], ); foreach my $head (keys %hoa) { my @data = @{$hoa{$head}}; my $item = shift(@data); print "$item,"; } print $/;
which produces as output

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://607039]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2020-10-19 15:34 GMT
Find Nodes?
    Voting Booth?
    My favourite web site is:

    Results (204 votes). Check out past polls.