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

Re^2: Syntax Perl Version support $c = () = $a =~ /\./g

by h2 (Beadle)
on Jul 17, 2018 at 20:03 UTC ( [id://1218692]=note: print w/replies, xml ) Need Help??


in reply to Re: Syntax Perl Version support $c = () = $a =~ /\./g
in thread Syntax Perl Version support $c = () = $a =~ /\./g

Anonymous monk, and that is precisely where that is being placed, inside of a one liner utility subroutine, that is documented as to what it tests, in this case, it returns 1, true, if the match is correct, and undefined, false, if not. As part of a larger test, but as a one liner. I have used arcane syntax like this internally in utility tools, and try to keep it out of the main logic that would be likely to get patches or pull requests. Documented, with comments, etc.

Now that this is confirmed safe, I'll be extending its use for all numeric tests (which is what this particular case is doing), and look into more secret type constructions for various utilities, that are not meant to be end user readable or serviceable, but are meant to be very very fast.

  • Comment on Re^2: Syntax Perl Version support $c = () = $a =~ /\./g

Replies are listed 'Best First'.
Re^3: Syntax Perl Version support $c = () = $a =~ /\./g
by eyepopslikeamosquito (Archbishop) on Jul 17, 2018 at 22:20 UTC

    Note that the content of the "anonymous" reply you replied to indicates it was authored by our Worst Nodes champion - who's recently introduced an annoying new tactic of replying "anonymously" ... and then sometimes agreeing with himself by replying to the "anonymous" post as sundialsvc4! I don't know why he's started doing this only recently.

    FWIW, I've often used the goatse operator in production code at work without wrapping it in a sub - though I always provide a one-line comment pointing to the goatse operator documentation. Having discussed the use of this operator during code reviews with a number of serious C++ programmers (but occasional Perl programmers) at work, I can report they've all been happy with this approach because, as skilled programmers, once they became aware it's a standard Perl idiom, they found the perlsecret documentation clear and easy to understand.

      In my case, I do want this wrapped up and safely out of view, because the potential contributors would be confused by such syntax, plus I do actually want it used as a utility subroutine to avoid scattering this type of stuff around the program, specifically to be able to update/tweak/optimize these tools as I go along. But thanks for the heads-up.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2024-04-25 13:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found