Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Re: The third 'if'

by danield (Novice)
on Jan 26, 2004 at 17:29 UTC ( [id://324186]=note: print w/replies, xml ) Need Help??


in reply to Re: The third 'if'
in thread The third 'if'

Hello Zaxo, Unfortunatelly I don't know how to implement 'last' or 'next', could you please be more specific?
In meantime I have tested a suggestion of a different person so the code now looks like:
#!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+/, $_); print "The current file has $monthfile and $yearfile\n"; print "And I am looging for $month and $year\n"; if ( $monthfile eq $month and $yearfile eq $year){ print "File has $yearfile and $monthfile in it. Now Looking fo +r Impressions.\n"; my $found = 0; until ($found) { my $line = <FH>; if ($line =~ /Impressions:/ ) { $found++; print "Found Impressions, now splitting.\n"; my($text, $value) = split(/:\s*/, $_); print $impressions += $value if ($value =~ /\d+/); print "\n"; } } } } } close FH or die $!; } } print OUT 'Total impressions: ', $impressions or die $!;

And the output I am getting now is:
Found Impressions, now splitting. Argument "Sat Nov 1 00" isn't numeric in add at c07c_imp.pl line 39, +<FH> chunk 13. 0 Found Sumary Log, checking the month and year. The current file has Nov and 2003) And I am looging for Nov and 2003) File has 2003) and Nov in it. Now Looking for Impressions. Found Impressions, now splitting. Argument "Sat Nov 1 00" isn't numeric in add at c07c_imp.pl line 39, +<FH> chunk 13. 0 Found Sumary Log, checking the month and year. The current file has Nov and 2003) And I am looging for Nov and 2003) File has 2003) and Nov in it. Now Looking for Impressions. Found Impressions, now splitting. Argument "Sat Nov 1 00" isn't numeric in add at c07c_imp.pl line 39, +<FH> chunk 13.

Replies are listed 'Best First'.
Re: Re: Re: The third 'if'
by arden (Curate) on Jan 26, 2004 at 18:29 UTC
    I think your line 38 should be my($text, $value) = split(/:\s*/, $line); instead of my($text, $value) = split(/:\s*/, $_);. It goes back to what Zaxo said about $_ haunting you. :)

    Your match in line 39 will be true if there is any digit in $value, if you want for only digits try /^\d+$/ instead, but in your case (where you know $value will have a number in it) you don't actually need that if statement.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://324186]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2024-04-19 23:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found