#!/usr/bin/perl
use strict;
use warnings;
my $path = "/tmp/dir1";
my %filesize = map { $_ => -s } <$path/d1*>;
my @sorted = sort { $filesize{$b} <=> $filesize{$a} } keys %files;
printf "Largest file: %s (%d bytes)\n", $sorted[0], $filesize{$sorted[0]};
####
#!/usr/bin/perl
use strict;
use warnings;
my $glob_pattern = shift || './*';
my %files;
for ( glob( $glob_pattern )) {
$files{$_} = -s _ if ( -e );
}
if ( scalar keys %files == 0 ) {
warn "No files matched $glob_pattern\nUsage: $0 [path/name*]\n";
exit(1);
}
my @sorted = sort { $files{$b} <=> $files{$a} } keys %files;
printf( "Largest file that matches %s is %s (%d bytes)\n",
$glob_pattern, $sorted[0], $files{$sorted[0]} );
####
show-biggest '/tmp/dir1/d1*' # note the single quotes
# or:
show-biggest /tmp/dir1/d1\* # note the backslash escape for "*"
####
my @files = ;
####
my $glob = "something";
my @files = glob( $glob );