develooper Front page | perl.beginners | Postings from December 2002

Directory help, AS

Thread Next
From:
Steve Few
Date:
December 30, 2002 08:35
Subject:
Directory help, AS
Message ID:
3E10758D.E2C855AC@ncmail.net
[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'.

Thanks!
Steve Few
NC DENR
Raleigh, NC
steve.few@ncmail.net

##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 <mgoland@optonline.net>
#       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";



Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About