in reply to Opinion: where Perl5 wasn't attractive for me

Some options always present themselves.

package lvals { sub import { shift; no strict 'refs'; *{caller.q(::).$_} = do{ my $x; sub () :lvalue {$x} } for @_; } } 1;
use lvals qw(i j matrix sum); matrix = [([1..10]) x 10]; for(i = 0; i < 10; i++) { for(j = 0; j < 10; j++) { sum += matrix->[i][j]; } } print "Matrix sum is ", sum;
Count the sigils. Yay!

/me quickly hides under the rock.

Replies are listed 'Best First'.
Re^2: Opinion: where Perl5 wasn't attractive for me
by BrowserUk (Patriarch) on Dec 12, 2014 at 04:18 UTC

    I missed this. I'm so glad that it was a slow night/morning when astroboy posted.

    ++ and props!


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
Re^2: Opinion: where Perl5 wasn't attractive for me
by LanX (Saint) on Nov 24, 2014 at 10:24 UTC
    +0.9 upvote

    full points only if you change the package block into a backwards compatible way! ;-)

    Cheers Rolf

    (addicted to the Perl Programming Language and ☆☆☆☆ :)

    PS: lvalue subs are unfortunately a little bit slow compared to real scalar variables...

      PS: lvalue subs are unfortunately a little bit slow compared to real scalar variables...

      Like in real life: You have to spend some $$ to get faster... :-)

      Regards
      McA

      P.S.: After working with Python for some time I think that sigils are not too bad. They give hints for the reader. But sure, it doesn't look so clean.

        > They give hints for the reader.

        Yep my main argument, better that this hungarian notation.

        Even more sigils for refs would be handy and help avoiding explicit dereferencing.

        But predominantly sigils are needed for imposing context.

        > But sure, it doesn't look so clean.

        and as always it's mostly about aesthetics...

        ... I was pondering about a highlighting add-on for emacs to hide sigils and semicolons with background color, to make Perl look like Ruby ;-)

        Cheers Rolf

        (addicted to the Perl Programming Language and ☆☆☆☆ :)

Re^2: Opinion: where Perl5 wasn't attractive for me
by astroboy (Chaplain) on Dec 12, 2014 at 03:49 UTC
    nice!