ActiveState Community

My first attempt at Perl

Posted by neilhmurphy on 2009-03-20 19:11

.
Below is a Perl program that is getting a diagnostic (Global symbol "$fle" requires explicit package name).

#!/usr/bin/perl -w
use strict;
use Scalar::Util qw(blessed dualvar isweak
readonly refaddr reftype tainted
weaken isvstring looks_like_number
set_prototype);
opendir(Dir1,"f:/spreadsheets/taxes/08 taxes");
$fle = readdir(Dir1);
print "$fle\n";

Any idea whats wrong? I realize that it will only do the first entry. I do not want a list (eg array) of names, just one name at a time.

reitzell | Fri, 2009-10-09 13:52

Ummm.... so, what you are trying to do here is read a directory and print the file names of that directory?

#!/usr/bin/perl -w

@files = <*>;
foreach $file (@files) {
print $file . "\n";
}

does that work for you?

Rob