danield has asked for the wisdom of the Perl Monks concerning the following question:
the my$iofile contains: 1. where the files I am interested are, 2. where to write the total, 3. and then the pattern (*Dec2003*.txt)#!usr/bin/perl -w use strict; use Fcntl qw[:flock]; my $impressions = 0; my$iofile = '/other/scripts/daniel/input/c07_impressions_io.info'; open (IO, $iofile) || die("Could not open file 1!"); while (<IO> ) { chop; (my$FH, my$output, my$file2check) = split (/\s+/, $_); open OUT, ">> $output"; chdir $FH or die "$!"; while (glob $file2check) { open FH, $_ or die $!; flock FH, LOCK_SH or die $!; while (<FH> ) { chomp; if ( /Impressions:/ ) { my($text, $value) = split(/:/, $_); $impressions += $value if ($value =~ /\d+/); } } close FH or die $!; } } print OUT 'Total impressions: ', $impressions or die $!;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to process only files created on specific month?
by Zaxo (Archbishop) on Jan 23, 2004 at 20:49 UTC | |
by Not_a_Number (Prior) on Jan 23, 2004 at 21:40 UTC | |
by danield (Novice) on Jan 23, 2004 at 21:05 UTC | |
by Zaxo (Archbishop) on Jan 23, 2004 at 21:54 UTC | |
by ysth (Canon) on Jan 23, 2004 at 22:06 UTC |