in reply to Contents of directory without extensions
#the pragmas, sorted alphabettically use diagnostics; use strict; use warnings; #the imported packages use English; use File::Spec::Functions; use File::Basename; # check if directory specified, else assumer current directory my $dir = ( scalar(@ARGV) > 0 ) ? $ARGV[0] : curdir(); my ( @files, $file, @files_wo_extn ); opendir( DIR, $dir ) or die "Could not open $dir, $OS_ERROR"; @files = readdir(DIR) or die "Reading entries in $dir, $OS_ERROR"; closedir(DIR); foreach $file (@files) { #check whether the file is a directory #need to use the directory and file to access the file unless ( -d catfile( $dir, $file ) ) { push @files_wo_extn, basename($file); } } print join "\n", @files_wo_extn; print "\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Answer: Contents of directory without extensions
by belg4mit (Prior) on Nov 25, 2001 at 07:34 UTC | |
by data64 (Chaplain) on Nov 25, 2001 at 09:25 UTC | |
by belg4mit (Prior) on Nov 25, 2001 at 09:28 UTC |