Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Hello all, I do have a file with this content:
------------- Summary Log (generated: Tue Apr 1 22:02:29 MST 2003) ------------- ZIP file: file_01.zip Detail log file: TA01Apr2003-01.zip.LOG PDF statements generated: 162 Impressions: 880 Hierarchy updates: 66 Movements performed: 19 Statements loaded: 162 Hierarchy errors: 0 Movement errors: 0 Statement errors: 0 ----------------- END Summary Log -----------------

and I do have this perl script:
#!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, $output, $file2check, $month, $year) = 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 ( / Summary Log \(generated:/ ) { print "Found Sumary Log, checking the month and year.\n"; my($emptyspce, $summary, $log, $generated, $day_word, $monthfi +le, $day_number, $time, $timezone, $yearfile ) = split(/\s+/, $_); if ( $monthfile eq $month and $yearfile eq $year){ print "File has $yearfile and $monthfile in it. Now Looking fo +r Impressions.\n"; if ( /Impressions:/ ) { print "Found Impressions, now splitting.\n"; my($text, $value) = split(/:/, $_); print $impressions += $value if ($value =~ /\d+/) +; print "\n"; } } } } close FH or die $!; } } print OUT 'Total impressions: ', $impressions or die $!;

When I run the script, it produces this output:
Found Sumary Log, checking the month and year. Found Sumary Log, checking the month and year. File has 2003) and Nov in it. Now Looking for Impressions. Found Sumary Log, checking the month and year. File has 2003) and Nov in it. Now Looking for Impressions. Found Sumary Log, checking the month and year. File has 2003) and Nov in it. Now Looking for Impressions.

The script should basically open a file, then check if it has 'Nov' and '2003)' in it.
If yes, the script then should check if there is a line with 'Impressions:' and if impressions has assigned a numeric value, it should then sum together the number of all impressions for the given month and year.
However, the script unable to find impressions. I had a simplier version of the same script and the portion of the code responsible for dealing with impressions did work. Now it does not work, and I have not changet that piece of code. Please, can anybody advice? Thank you for your time. danield

In reply to The third 'if' by danield

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (3)
As of 2024-03-29 06:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found