[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Omaha.pm] My first hash slice




On Oct 1, 2008, at 2:34 PM, <jay@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@petdance.com => www.petdance.com => AIM:petdance