Home: Perl Programming Help: Beginner:
opening a file with the name of what they entered



Killian
Deleted

Apr 27, 2001, 10:34 PM


Views: 185
opening a file with the name of what they entered

I am trying to make my script check to see if a txt file already exists, if it does, do one thing, if it doesn't do another.

The problem is I want it to check if "whatever-they-typed-into-the-form.txt" exists.

I have put the info into an associatie array so to check what they typed in I just do $associative_array{'name'} and it shows what they typed in for the name field on the form.

I have tried the following:

if (-e '$associativearray{'name'}.txt')
{
do thing a
}
else
{
do thing b
}

but every time i do this is does thing b even when I have a file called moo.txt and I type in moo for the name field... what am I doing wrong?



zanardi
journeyman

Apr 27, 2001, 11:24 PM


Views: 182
Re: opening a file with the name of what they entered


Code
if (-e "$associativearray{'name'}.txt")

the way you had it, you were actually searching for a file named $associativearray{'name'}.txt.

----------------------
Fueled By ZCom