Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: AJP ping

by Anonymous Monk
on Jul 07, 2011 at 15:55 UTC ( #913212=note: print w/replies, xml ) Need Help??


in reply to AJP ping

Thanks for saving me a chunk of time. A few minor tweeks were needed for me to make it work properly, the most critical was swapping out the "||" for an actual "or", the bitwise operator didn't seem to be catching the return values properly. A bit more to add and it'll be a fully functional nagios plugin A

Replies are listed 'Best First'.
Re^2: AJP ping
by jffry (Hermit) on Nov 18, 2011 at 22:37 UTC

    Actually, || is not a bit-wise operator.

    The reason that my statements like this:

    socket $sock, PF_INET, SOCK_STREAM, $proto || die $!;

    ...aren't dying properly is because , has lower operator precedence than ||. The or operator has the lowest precedence. See the perlop docs.

    This means that statement was evaluated like this:

    socket $sock, PF_INET, SOCK_STREAM, ($proto || die $!);

    ...instead of like this:

    socket ($sock, PF_INET, SOCK_STREAM, $proto) || die $!;

    And this is now making me question the wisdom of PBP's rules of:

    Don't use unnecessary parentheses for builtins and "honorary" builtins.
    Because I was thinking that functions in the Socket module were essentially honorary builtins.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2023-03-31 13:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which type of climate do you prefer to live in?






    Results (75 votes). Check out past polls.

    Notices?