Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help with a hash please 1

Status
Not open for further replies.

perlescent

Technical User
Apr 7, 2005
23
GB
Having run a number of loops, I have built two arrays. Then I have used Data::Dumper to remove duplicate entries from each array

eg @vacantRooms = 29 30 01 20 03 04 05 29 30 01 02 30 01;
is now, 29 30 01 02 03 04 05;

similar done for @nights Requested.

But how do I build a hash so that the rooms vacant on a certain date (eg 01) are shown with the room number?

Code:
for (@vacantRooms) { $vacant{$_}++; }
    #print Dumper %vacant;

  for $room (keys %vacant) {
    if ($numberOfNightsRequested == $vacant{$room}) {
      print "room = $room<br />"; prints the room numbers available on the selected dates.  
      #print "ARoom $room vacant for $vacant{$room} nights\n";
      #return $room;
      #print "\tnumber Of Nights Being Checked == nights vacant\n";
    }

   for (@nightsRequested) { $nights{$_}++; }
      for $requested (keys %nights) {
        #push (@nightsOfVisit, $requested);
       
print "req = $requested<br />"; # shows the dates 29 05 30 01 02 03
$available{$room}{$requested}= $_; # doesn't work yet.

print <<eof;

available = $available<br />
avaialbel{room} = $available{$room}<br />

eof

}
}

bazz
 
Solved.

I used a different array that I had already compiled (and forgotten about), in my sub. A simple conditional gave the much-desired result :)

bazz
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top