in reply to Re: Show different text based on random number
in thread Show different text based on random number

&sub is a perfectly valid Perl5 syntax. Is true that the author must be aware of side effects.

L*

There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

Replies are listed 'Best First'.
Re^3: Show different text based on random number
by Your Mother (Archbishop) on Apr 22, 2016 at 11:17 UTC

    I didn't say it was invalid, I said it was perl4 style with gotchas. I don't think I've ever seen a Seeker of Perl Wisdom who uses it and is aware of its side-effects. :P It whispers cargo-cult and cgi-lib.pl to me.

      I'm not for sure a model for others perl programmers, but i still use it, and i'm aware of what i'm doing (disable prototypes and pass current @_ to the sub, but just in case of ⊂ ), to visually tell at glance locally (same file) defined subroutines from others imported by used modules.

      perlsub states:

      The & is optional in modern Perl, as are parentheses if the subroutine has been predeclared. The & is not optional..

      L*

      There are no rules, there are no thumbs..
      Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
        > to visually tell at glance locally (same file) defined subroutines

        That seems to be your convention, but Perl allows you to &-sigilize an imported subroutine:

        #!/usr/bin/perl use warnings; use strict; use feature qw{ say }; use POSIX; say &ceil(1.23);

        ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,