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

[Omaha.pm] My first hash slice



Huh. I think I just coded my first hash slice in the wild (the 'my $key ='
line). I blame Andy Lester for posting array slices last year.

Is this code evil?

   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;
      }
   }

In the debugger, below...

Ponder,

j



78:           my $key = join "|", @$href{ qw(rate_cat room_code
hrms_room_cat stod etod) };
                                                                           
                                        DB<2> x $href
0  HASH(0x8d8d3cc)
   'accepted_len_stay' => 'YYYYYYY'
   'break_point' => 109
   'current' => 'N'
   'etod' => 1600
   'hrms_room_cat' => 'DELUXE'
   'length_of_stay' => 'YYYYYYY'
   'rate_cat' => 'CR'
   'room_code' => 5637
   'stod' => 1200
                                                                           
                                        DB<3> n
Omni2::Control::OmniCRS::HRMS::Band1::load_from_omni_crs(/home/jhannah/src/Omni2/Control/OmniCRS/HRMS/Band1.pm:79):
79:           print "$key\n";
                                                                           
                                        DB<3> n
CR|5637|DELUXE|1200|1600