[Omaha.pm] My first hash slice
Andy Lester
andy at petdance.com
Wed Oct 1 12:48:25 PDT 2008
On Oct 1, 2008, at 2:34 PM, <jay at jays.net> wrote:
> while (my $href = $sth->fetchrow_hashref) {
> foreach my $key (keys %$href) {
> $href->{$key} =~ s/\s+$//;
> }
> $DB::single = 1;
> my $key = join "|", @$href{ qw(rate_cat room_code hrms_room_cat
> stod
> etod) };
> print "$key\n";
> unless ($self->_Band2s->{$key}) {
> my $b2 = Omni2::Control::OmniCRS::HRMS::Band2->new($href);
> $self->_Band2s->{$key} = $b2;
> }
> }
Now, note that you have a $key in the foreach loop, AND you're
overriding it inside the loop, too. That's confusing.
Also, how about instead of
print "$key\n";
you use
say $key;
xoxo,
andy
--
Andy Lester => andy at petdance.com => www.petdance.com => AIM:petdance
More information about the Omaha-pm
mailing list