Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

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

by Anonymous Monk
on Jul 17, 2018 at 19:42 UTC ( #1218688=note: print w/replies, xml ) Need Help??

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

And wouldn't it be the perfect thing to put in a descriptively-named one line subroutine that hides the Perl-voodoo in only one place, and tells everyone else exactly what it's supposed to do? Mmmmm....? Perl has lots of ways to write something such that you don't know at a glance what it's supposed to do, and it doesn't actually do what you intended for it to do or thought that it did, either. Sure would be nice to be able to fix any problems in one place.
  • Comment on Re: Syntax Perl Version support $c = () = $a =~ /\./g

Replies are listed 'Best First'.
Re^2: Syntax Perl Version support $c = () = $a =~ /\./g
by Your Mother (Bishop) on Jul 17, 2018 at 20:50 UTC
    Perl has lots of ways to write something such that you don't know at a glance what it's supposed to do

    Well… Perl programmers do. It's weird… it's like this site is almost dedicated to those people. Maybe a name change would help combat the lack of clarity perptually befuddling you. s/Perl Monks/Perl Programmers Who *Like* Perl and Also Enjoy Learning, Exploring Problems, and Helping Their Community; Unemployable PMs Are Welcome to Participate Providing They Remain Respectful and Don't Become Founts of Acrimony or Wasted Time for Years on End/g;

Re^2: Syntax Perl Version support $c = () = $a =~ /\./g
by h2 (Sexton) on Jul 17, 2018 at 20:03 UTC

    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.

      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.
Re^2: Syntax Perl Version support $c = () = $a =~ /\./g
by Anonymous Monk on Jul 24, 2018 at 18:21 UTC
    "and tells everyone else exactly what it's supposed to do?" It does. You big dummy.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2020-10-28 21:06 GMT
Find Nodes?
    Voting Booth?
    My favourite web site is:

    Results (264 votes). Check out past polls.