#! perl -slw
use strict;
opendir DH, "." or die $!; # open current directory
while($_ = readdir(DH)){
# don't evaluate special dirs '.' & '..'
next if $_ eq "." or $_ eq "..";
print "$_"; # print this file/directory's name
}
__END__
####
#! perl -slw
use strict;
my @files = glob("*");
print "Files matched via glob pattern *: @files\n";
__END__
####
#! perl -slw
use strict;
opendir DH, "." or die $!; # open current directory
while($_ = readdir(DH)){
# don't evaluate special dirs '.' & '..'
next if $_ eq "." or $_ eq "..";
print "$_"; # print this file/directory's name
# as a by-product of readdir; use the file's stat info
# to check whether this is indeed a regular file we can
# open for reading/further processing
if (-f $_) {
open FH, "<$_" or die $!;
print "output for file: $_\n";
while (my $line = ) {
print $line;
}
close FH;
}
}
__END__
####
if ($filename =~ /.txt/)
####
if ($filename =~ /\.txt/)