opendir (DIR, "/home/skhan01/perl/file_tests") || die "Can't open directory: $!"; my @files = readdir(DIR) foreach(@files) { print ("File exist!\n") if ($_ =~ /^vista90n/ && -e $_); #print if file starts with vista90n and it exists. } #end foreach
Not tested Etienne > "Khan, Sajid" wrote: > > Hi Guys > > I am running into an issue trying to determine whether a file exists > when the name varies. > The file has a name that always begins with "vista90n" and so I tried > the following code ... > > if (-e "/home/skhan01/perl/file_tests/vista90n*") { > print ("Files exist!\n"); > } > > apparently wildcards don't work in this way using the "-e" switch. > Does anyone know how > to use wildcards with the "-e" switch or do I have to create a list of > file names and parse them? > I even tried using the "\*" but no dice .... > > Thanx > Saj > > Sajid Khan > Tivoli Systems Engineer > Carolinas Healthcare System > (704) 446-8030 > > *********************************************************************** > This electronic message may contain information that is confidential > and/or legally privileged. It is intended only for the use of the > individual(s) and entity named as recipients in the message. If you > are not an intended recipient of this message, please notify the > sender immediately and delete the material from any computer. Do not > deliver, distribute or copy this message, and do not disclose its > contents or take any action in reliance on the information it > contains. Thank you. > > --------------------------------------------------------------- > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] -- Etienne Marcotte Specifications Management - Quality Control Imperial Tobacco Ltd. - Montreal (Qc) Canada 514.932.6161 x.4001 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]