Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Can you spot the problem?

by ambrus (Abbot)
on Mar 05, 2004 at 18:59 UTC ( #334326=note: print w/replies, xml ) Need Help??


in reply to Can you spot the problem?

I wonder weather this code could possibly work in perl6, where the | operator will mean something else (see Exegesis 6).

Replies are listed 'Best First'.
Re: Re: Can you spot the problem?
by TimToady (Parson) on Mar 05, 2004 at 19:48 UTC
    Works if you change the all the |s to &s. (Plus you can omit the parens if you're golfing, since junctions now bind tighter than comparisons. Well, okay, you can omit the parens even if you're not golfing.)

      I'd rather leave the |'s and change the comparison from "if ... <256" to "unless ... >255". That way the puzzle still works in perl5.

        I like making it all into one logical return expression, with no conditionals.

        Without the two character fix/spoiler:

        sub isValidIP { return (shift =~ m/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/ and (($1|$2|$3|$4) + < 256)); }
        Update: I wasn't offering a Perl 6 solution, despite the subthread my response was in. That would be
        return (shift =~ m/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/ and not (($1|$2|$3 +|$4) > 255));

        The PerlMonk tr/// Advocate

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://334326]
help
Chatterbox?
[choroba]: You have to find out why it happened. Was there an OS update?
[vedagiri89]: that is what i can't getting solution
[vedagiri89]: recently purchased centos server and doing migration of app
[choroba]: did you copy any dependencies?
[choroba]: all XS code needs to be recompiled
[vedagiri89]: install perl5.16 in the new server and try to run appache
[hippo]: Which version of CentOS?
[vedagiri89]: how to fix: Attempt to reload DynaLoader.pm aborted
[hippo]: Ah, presumably 7 then.

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (8)
As of 2018-06-19 11:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?



    Results (113 votes). Check out past polls.

    Notices?