Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Opinion: where Perl5 wasn't attractive for me

by oiskuu (Hermit)
on Nov 24, 2014 at 07:50 UTC ( [id://1108234]=note: print w/replies, xml ) Need Help??


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!

Log In?
Username:
Password:

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

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

    No recent polls found