Advertisement
cd62131

Read Files and Print Total

Jan 18th, 2014
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.26 KB | None | 0 0
  1. #!/usr/bin/perl
  2. use strict;
  3. use warnings;
  4. use utf8;
  5. use open qw(:encoding(utf8) :std);
  6. use feature 'say';
  7. my $total = 0;
  8. foreach (glob "${ARGV[0]}/*.dat") {
  9.   open my $in, '<', $_;
  10.   while (<$in>) {
  11.     $total += $_;
  12.   }
  13.   close $in;
  14. }
  15. say $total;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement