note
dbuckhal
<p>One thing that has helped me in similar situations was to change into the directory containing the files of interest. For example, note the tiny changes to your code:</p>
<code>
use strict;
use warnings;
use Data::Dumper qw(Dumper);
use File::Spec;
use Digest::SHA qw(sha256_hex);
print join("\n", @ARGV),"\n\n";
#print Dumper \@ARGV;
my $dir = $ARGV[0];
my $url = $ARGV[1];
my @array;
opendir DIR, $dir or die "cannot open dir $dir: $!";
chdir $dir; # added chdir
while(my $file = readdir DIR) {
next unless -f $file; # simplified file check
next if($file =~ m/^\./); # removed quotes
print "${\File::Spec->rel2abs($file)}\n";
my %hash = (
path => File::Spec->rel2abs($file),
size => -s $file,
id => sha256_hex($file),
);
push(@array, \%hash);
}
closedir DIR;
print Dumper sort \@array;
</code>
<p>Hope it works out for you!</p>
<p>--Derrick</p>
1205139
1205139