Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re: IP Accounting parser

by turnstep (Parson)
on Jan 12, 2001 at 02:52 UTC ( #51245=note: print w/ replies, xml ) Need Help??

in reply to IP Accounting parser

Erk! This code:

open FILE, $logfile || die $!;
does not act the way you want it to. Because the || has a higher precedence than the comma, what actually happens is this:
open FILE, ($logfile || die $!);
see perlop for the complete precedence list.

If you really want to use the || then put parenthesis around things like so:

open (FILE, $logfile) || die "Could not open $logfile: $!\n";

Better yet, use the super-low-priority or, which allows you to acheive your original effect:

open FILE, $logfile or die "Could not open $logfile: $!\n";

Best of all, be correct and non-ambigous and use both:

open (FILE< $logfile) or die "Could not open $logfile: $!\n";

Comment on Re: IP Accounting parser
Select or Download Code
Replies are listed 'Best First'.
Re: Re: IP Accounting parser
by Viking (Beadle) on Jan 12, 2001 at 08:58 UTC
    I always get || and or mixed up, I will attempt to burn the precedence list into my brain.

      It may help to think of or and and as 'lowercase', and thus 'lower precedence' as opposed to || and && which require the use of the shift key, and therefore are 'uppercase' and 'upper precedence'

      You could also just remember that nothing is lower in precedence than and and or

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (5)
As of 2015-11-27 21:00 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (732 votes), past polls