not quite. Getting these errors...

perl test.pl "d:/mywork/" "123"

Global symbol "line" requires explicit package name at test.pl line 12.
Variable "$line" is not imported at test.pl line 13.
Global symbol "line" requires explicit package name at test.pl line 13.
Variable "$line" is not imported at test.pl line 13.
Global symbol "line" requires explicit package name at test.pl line 13.
Variable "$line" is not imported at test.pl line 15.
Global symbol "line" requires explicit package name at test.pl line 15.
Variable "$line" is not imported at test.pl line 16.
Global symbol "line" requires explicit package name at test.pl line 16.
syntax error at test.pl line 17, near "}"
syntax error at test.pl line 20, near "}"
Execution of test.pl aborted due to compilation errors.


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

On Friday 06 May 2005 16:50, macromedia wrote:
> 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;
> }
>

Looks good. Does it work?

>
> -----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>

-- 
Just getting into the best language ever...
Fancy a [EMAIL PROTECTED] or something 
on http://www.perl.me.uk Just ask!!!

-- 
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