Bowlslaw has asked for the wisdom of the Perl Monks concerning the following question:
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: $!"; while(my $file = readdir DIR) { next unless(-f "${\File::Spec->catfile($dir, $file)}"); next if("$file" =~ m/^\./); 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;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: -s file test operator only works in same directory
by NetWallah (Canon) on Dec 08, 2017 at 02:12 UTC | |
by Bowlslaw (Acolyte) on Dec 08, 2017 at 03:31 UTC | |
by NetWallah (Canon) on Dec 08, 2017 at 05:41 UTC | |
by Bowlslaw (Acolyte) on Dec 08, 2017 at 13:00 UTC | |
Re: -s file test operator only works in same directory
by Dallaylaen (Chaplain) on Dec 08, 2017 at 07:54 UTC | |
Re: -s file test operator only works in same directory
by dbuckhal (Chaplain) on Dec 08, 2017 at 03:22 UTC | |
Re: -s file test operator only works in same directory
by hippo (Archbishop) on Dec 08, 2017 at 09:16 UTC |