# supersearch this one - short version: it detects most common coding errors. # always use it. use strict; sub lsForCorp { my $corp = $_[0]; # File::Spec allows you to create a directory structure in # a platform-independant manner. Not a big deal to you since # this probably only runs on unix anyway, but all my code # has to run on both unix and Windows, so it's just a # habit. require File::Spec; my $path = File::Spec->catfile( # this reconstructs the path - if you print $path, you'll # see exactly the path you were using - again, no big deal # if portability is unimportant (and "/usr/local" is not # really portable either ;->) File::Spec->rootdir(), qw(usr local farms * * input), "*$corp*" ); # let glob do all the work rather than ls. Besides, ls # calls the same thing as glob under the covers, more or # less. (Technically, it's the shell.) my @farms = glob($path); foreach my $farm (@farms) { # no if statement since the glob already only gets files that match # *$corp*, which is the glob way of saying /\Q$corp/. print $farm, "\n"; } # end of foreach statement } #end of lsForCorp subroutine #------------------- End Subroutines ---------------------# print "What corp are you looking for? " ; # chomp it to remove the trailing newline. chomp(my $whatWeWant = ); # & doesn't do what you think it does - avoid it unless you # actually mean to do what it does. lsForCorp($whatWeWant); #### use File::stat; # ... my $s = stat($farm); printf "%s: Age [%s], size [%d]\n", $farm, $s->mtime(), $s->size();