Skip to content

Instantly share code, notes, and snippets.

@zsan
Created October 9, 2012 20:02
Show Gist options
  • Save zsan/3861078 to your computer and use it in GitHub Desktop.
Save zsan/3861078 to your computer and use it in GitHub Desktop.
simple example of the power File::Find
#!/usr/bin/env perl
use Modern::Perl;
use File::Find;
#--------------------------------------------------
# no getopt since its very simple
#--------------------------------------------------
die "Enter a directory to search\nUsage: perl $0 <dir_path>" unless @ARGV;
my $total_size = 0;
find(sub { $total_size += -s if -f }, $ARGV[0]);
say $total_size;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment