On Thu, 8 Jul 2004 15:17:55 -0500 , Brian Volk <[EMAIL PROTECTED]> wrote:
> Hi All,
> 
> Below is the program I'm using... It works but I'm getting an error
> message... Can you please tell me what I'm doing wrong?  I listed the error
> below... Thanks so much for all your help.  PS:  The program will not fun if
> I use strict;
> 
> ------------------------------ start
> -----------------------------------------------------------
> 1   #!/usr/bin/perl -w
> 2
> 3   use Regexp::Common qw /URI/;
> 4
> 5   $dir = "/Program Files/OptiPerl/test_files";
> 6           opendir (BIN, $dir) or die "Can't open $dir: $!";
> 7           while ( defined ($file = readdir BIN) ) {
> 8
> 9   # -----------  load @ARGV for <> operator --------------------
> 10
> 11 @ARGV = grep { !/^\./ } readdir BIN;
> 12
> 13          while (<>) {
> 14          print "$ARGV contains an HTTP URI\n" and close(ARGV) and next
> 15               if /$RE{URI}{HTTP}/;
> 16
> 17      }
> 18
> 19       closedir (BIN);
> 20 }
> 
> ************ error I'm getting / program works ************
> 
> Name "main::file" used only once: possible typo at C:\Program

That means that you've only used the variable $file once. Why are you assigning
to a variable and never using the variable for anything else? The compiler is
warning you that you might have a typo, because it's not normal to assign to
a variable and never use it.

You say that the program will not run if you use strict. If you
declare your variables
using "my", like "my $dir = ...", then the program should run using
strict. This will
help you to find errors, so you should consider doing it.

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