> -----Original Message-----
> From: Steve Few [mailto:[EMAIL PROTECTED]]
> Sent: Monday, December 30, 2002 11:34 AM
> To: [EMAIL PROTECTED]
> Subject: Directory help, AS 
> 
> 
> [activeperl 5.6.1 NT]
> 
> Folks.
> 
> I have an 'error' question about lexical scoping.
> 
> This is a followup to the Mark Goland's reply to help someone. I
> have a question about an error I'm not familiar with using his
> {opendir local} statement. After I run the below on my NT box, AS
> build 622, I get:
> 
> '...Global symbol "$TMP" requires explicit package name at
> opendir_.pl at line 13'.

That error is because of "use strict". Changing "local $TMP" to "my $TMP",
or adding "our $TMP" above the unless() will get rid of the error.

But, it looks like he's just checking that $ARGV[0] is a directory. This can
be accomplished with a simple -d test.

   die "Expected directory\n" unless @ARGV && -d $ARGV[0];

> 
> Thanks!
> Steve Few
> NC DENR
> Raleigh, NC
> [EMAIL PROTECTED]
> 
> ##code below ##
> 
> #!/usr/bin/perl -w
> use warnings;
> use strict;
> #  Steve Few, directory browsing
> #     Re: Directory and its sub-directory disk usage: Windows '98
> #  thanks to ->  Mark Goland <[EMAIL PROTECTED]>
> #       Sun, 29 Dec 2002 21:59:41 -0500
> #
> 
> my $Size;
> my @FILES;
> unless(opendir local $TMP,$ARGV[0] ){
>  print "-------------invalid directory-------------\n";
>  print "USAGE:\n\t\t$0 directory to parse";
>  exit 1;
> }
> chomp (@FILES=`dir /s /b $ARGV[0]`);
> for ( @FILES ){
> 
> ( $Size+= (stat $_)[7] );
> }
> 
> print "TOTAL SIZE: $Size bytes \n";
> 
> 
> 
> -- 
> 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