in reply to Re^2: No Filenames Returned
in thread No Filenames Returned
and in the code, instead of die, use croak, like this (I added a carriage return at the end to make it more readable):use Carp;
That may give your more verbose information. I find it very useful in my code, as it gives a trace of the subroutine calls, values passed in, etc.opendir (DIR, $path) or croak "Unable to open $path: $!\n";
Update: here's the entire code, as it worked for me. I noticed that you had a typo in your die statement, too - it should be $!, not ! or 1.
#!/usr/bin/perl use strict; use warnings; use Carp; sub processFiles { my $path = shift; opendir (DIR, $path) or croak "Unable to open $path: $!"; my @files = readdir (DIR); closedir (DIR); foreach my $myfile (@files) { print "Files: $myfile\n"; } } print "$0 started at " . (localtime) . "\n"; processFiles(@ARGV); print "$0 finished at " . (localtime) . "\n";
-- Burvil
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: No Filenames Returned
by coolboarderguy (Acolyte) on Mar 23, 2006 at 11:41 UTC |