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

File Testing

Status
Not open for further replies.

SlykFX

Programmer
Oct 12, 2002
76
GB
I cant seem to find any info about file testing anywhere :(

what i want is to test if a file exists, if so do one thing if not do something else.

what i have so far is an if statement however i dont know what it should be testing for :(

also if u know of any good resource/reference/information sites the URL would be much appreciated :)

thanks for any help in advance :) I can't be bothered to have a sig!
 
I think this is what you are looking for.

if (-e /path/to/file){ ...do somthine...}

OR

#otherfunction(); will be called if file cannot be opened.

open (DB, ">$dir/$DB_file[0].txt") or otherfunction();
while (my($k,$v) = each %$params) {
print BD "$k=$v&";
}
close (DB);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top