hello,
Quick question,
what does this line do?
push(@files,$File::Find::name) if (/$ending$/i);
I wrote a simalor script to find a certain file on my computer and the only
way I got it to work was by using this code in my WANTED sub
if ( File::Find::name eq File::Find::dir/$file ) {
print "matches..."
}
that isn't the exact way it way written...
does the pushing of the array of @files do the same thing?
thanks for you time,
James Lile
-----Original Message-----
From: Peter Kappus [mailto:[EMAIL PROTECTED]
Sent: Wednesday, April 02, 2003 3:35 AM
To: Shawn Sharp
Cc: [EMAIL PROTECTED]
Subject: RE: searching for files using perl
Shawn Sharp wrote:
> I created the following code to search for extention .PBD files in the
> htdocs/PBD folder while using the apache webserver. However it will only
> search in the cgi-bin folder for these files. What am I doing wrong?
If you're just searching for files, this is probably a great opportunity to
use the File::Find module. I reinvented the wheel about four times before I
discovered this one...d'oh!
oh yeah, perldoc Find::File
try this:
#!/usr/bin/perl -w
use File::Find;
use strict;
use warnings; #HEY! Do i need this with -w? somebody tell me...
my $root = "C:/temp"; #directory to start from
my $ending = ".pbd"; #extension to search for
my @files; #our list of found files
#go look for it...
#pass our subroutine for processing each file and the root dir
find(\&gotIt, $root);
#print our list all pretty like, with linebreaks
print join("\n",@files);
sub gotIt{
push(@files,$File::Find::name) if (/$ending$/i);
}
-good luck.
pk
--
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]