Hudson T Clark wrote:
Everything here look in order? Because it still leaves the directory
"Media"...
#!/usr/bin/perl -w
use strict;
# print scalar @dirlisting;
# $# is the index to the last item in the array, not the size.
#print "Enter the location of the favorites:\n";
#chomp(my $Dir = <>);
my $dir = 'D:\docume~1\admini~1\favorites\\';
opendir DIR, $dir;
my @dirlisting = readdir(DIR);
closedir DIR;
splice @dirlisting, 0, 1;
splice @dirlisting, 0, 1;
my $loop;
for($loop = 0;$loop < scalar @dirlisting;$loop++) {
unless(-T "$dir$dirlisting[$loop]") {
splice @dirlisting, $loop, 1;
}
}
foreach (@dirlisting) {
print "$_\n";
}
You can't splice inside a for loop without adjusting the loop index.
Try this instead:
use strict;
my $dir = 'D:/docume~1/admini~1/favorites';
my @textfiles;
opendir DIR, $dir or die "opendir: $!";
while (readdir DIR) {
next if /^\.{1,2}$/;
push @textfiles, $_ if -T "$dir/$_";
}
closedir DIR;
foreach (@textfiles) { print "$_\n"; }
__END__
--
,-/- __ _ _ $Bill Luebkert ICQ=162126130
(_/ / ) // // DBE Collectibles Mailto:dbe@;todbe.com
/ ) /--< o // // http://dbecoll.tripod.com/ (Free site for Perl)
-/-' /___/_<_</_</_ Castle of Medieval Myth & Magic http://www.todbe.com/
_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs