Something like this?

#!/usr/bin/perl -w

#Syntax: test.pl "<directory>" "<match>"

require 5.000;
use strict;

# Pass filename parameter
my $path = $ARGV[0];
my $num = $ARGV[1];

while ($line = <$path*.txt>) {
open (FILE, $line) or die "cannot open $line: $!\n";
      while (<FILE>) {
         if ($line =~ /$num/ {
             print $line;
        }
}
close FILE;
}



-----Original Message-----
From: Gavin Henry [mailto:[EMAIL PROTECTED] 
Sent: Friday, May 06, 2005 11:24 AM
To: beginners@perl.org
Subject: Re: Writing my first perl script

<quote who="macromedia">
>
> Hello,
>
> I'm not sure about the login or how I should approach what I want to
> achieve. I require a script that does the following.

Here are the quick answer, which provide you some reading material:

>
> 1. Search a directory and all sub-directories for a certain file
> extension. (Ex. .txt)

If you are famliar with the Unix find command, you can use find2perl;;

http://perldoc.perl.org/find2perl.html

>
> 2. Get the results of the above search and check "inside" each file
for
> a string match. (Ex. "123").

You would use a while loop,  Filehandle and some regular expressions:

http://perldoc.perl.org/perlopentut.html
http://perldoc.perl.org/perlrequick.html
http://perldoc.perl.org/perlfaq5.html


>
> 3. List the matches found into an external file for further
processing.

See above.

> What features should I be looking at to achieve this? Anyone know of
> some good examples that I could pick away at?
>

See above.

>
>
>
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
>
>
>


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to