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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help with conditional please

Status
Not open for further replies.

perlescent

Technical User
Apr 7, 2005
23
GB
I am sorting through a list of filenames within a dir.

Opening the filenames I can read the bookingReference in a hash.

if ($accommodations{$Keyword}) {
$booked = 1;
last;
} # end if

if ($booked) {
&booked;
} else {
&vacancies;
}

The difficulty is that both instances will be true, most often. I need to & booked if no vacancies and &vacancies if there is even just one vacancy. But how do I evaluate the hash. is that even the correct term?

perlescent.
 
you should find your scripts will be slashed in size and will be easier to read than having to deal with CSV, pipe delimited or any other type of flat file system.

It took me a week to get my head around the WIN32:ODBC module, but once I had that licked I wrote my own SQL module to make life easier.

Now instead of a whole load of file open, chomp, foreach, split, assign, change, put back into file, etc... etc...

that goes with flat file handling now all I use is...

Code:
my @rs = &getSQL("Members","FirstName,LastName,Telephone,Fax,Email","UserID='myuserid'");
How about that for getting a record set array of hashes. or to do an update
Code:
my $rec = &updSQL("Members","Password='newpassword'","UserID='myuserid'");
$rec will = no. of records updated, same for delete.
Code:
my $rec = &delSQL("Members","UserID='myuserid'");
think how may lines of code and calculating you need to write to open a file and find a specific record, update the data or remove a record.

with SQL you only need 1 line! (well with the help of my module :) )


"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top