Hi, Try this.
it creates an array of all files in the $dir directory that begin with
vista90n

$dir = "some path";

 opendir(DIR,$dir) or die "Cannot open directory $!";
 my @list = sort grep(/^vista90n/, readdir(DIR));


Regards
Mark Kneen

----- Original Message -----
From: "Etienne Marcotte" <[EMAIL PROTECTED]>
To: "Khan, Sajid" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Tuesday, December 18, 2001 4:27 PM
Subject: Re: How do you check for a file with a varying extension with the
"-e" option?


> I forgot
> closedir(DIR) || warn "Error closing directory: $!"; # (which is always
> good to do)
>
> There is probably a way of doing it with one line, maybe with the funky
> functions like map, but I don't know them...
>
> And you can use another weirdo function, grep, to remove the "." and
> ".." and all non-vista90n* files when doing your readdir, but for that a
> perl guru will have to answer.
>
> Etienne
>
> Etienne Marcotte wrote:
> >
> > 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]
>
> --
> 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]
>
>


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to