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

Re: using smartmatch for range matching

by tybalt89 (Monsignor)
on Nov 25, 2023 at 17:44 UTC ( [id://11155823]=note: print w/replies, xml ) Need Help??


in reply to using smartmatch for range matching

There is  1416 <= $number <= 1494 in later perls.

Replies are listed 'Best First'.
Re^2: using smartmatch for range matching
by LanX (Saint) on Nov 25, 2023 at 18:10 UTC
    IMHO it's also MUCH more efficient than the smartmatch, which will check against every element of a potentially huge temporary array, instead of just the boundaries.

    Edit

    And certainly better readable.

    Saying so, having an in LIST operator wouldn't harm, but that's not the demonstrated use case.

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    see Wikisyntax for the Monastery

      Sorry, but this sticks out like a sore thumb!

      And certainly better readable.

      Either:

      And certainly better readability.

      Or maybe:

      And certainly more readable.

             :-)
      
      Naked blocks are fun! -- Randal L. Schwartz, Perl hacker
        Broken English is the most spoken language in the world. Better adapt! ;p

        Funny enough, I literally just read a discussion in the guardian where a bunch of Brits were discussing how easy English supposedly was.

        The less languages they knew, the more confident they were ... xD

        Cheers Rolf
        (addicted to the Perl Programming Language :)
        see Wikisyntax for the Monastery

        PS: "He who learns a new language acquires a new soul" - Czech proverb(?)

Re^2: using smartmatch for range matching
by perltux (Monk) on Nov 25, 2023 at 18:19 UTC
    Thank you, that's a good alternative, but i will have to figure out the minimum Perl version required to use this, does anyone know when it was introduced?

      perl5320delta

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2024-05-18 03:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found