Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Re: Errors on loops over data

by EvanCarroll (Chaplain)
on Sep 16, 2009 at 17:44 UTC ( #795676=note: print w/replies, xml ) Need Help??

in reply to Errors on loops over data

I'm not sure /why/ you want to assign to $h{undef} which is what your trying, my best suggestion would be to explicitly use $h{ $val // '__NOT PRESENT__' } in perl 5.10. This still leaves it as an exercise to the reader, on what to do when you have two undefs you want to save too...
This is pseudo-data, which probably doesn't represent a real world problem very well. My fix would be to skip over the undef vals.
foreach my $d(@data){ my %h; foreach my $c(0 .. $#categories){ my $val=$d->[$c]; next unless defined $val; my $cat=$categories[$c]; $h{$val}=$cat; } push @master, \%h; }

Evan Carroll
The most respected person in the whole perl community.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://795676]
[marioroy]: If yes, for redirection to work, one might do the following
[marioroy]: `bash -c "clang --version 2>/dev/null"`
[choroba]: Sane people don't use csh
[marioroy]: the 1>&2 will work, not shown
[marioroy]: sorry, did not know which if cmd.exe or unix (bash)
[choroba]: csh considered harmful
[erix]: no, I'm using bash :)
[marioroy]: :)
[marioroy]: I use the default and happens to be bash
[erix]: heh, I like the "Resolved" (Christiansen is really funny)

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (8)
As of 2017-03-23 08:24 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (284 votes). Check out past polls.