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

Directory help, AS

Thread Next
Steve Few
December 30, 2002 08:35
Directory help, AS
Message ID:
[activeperl 5.6.1 NT]


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 at line 13'.

Steve Few
Raleigh, NC

##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 <>
#       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 Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About