Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Re: Script/module formatting gotcha

by jettero (Monsignor)
on Oct 06, 2010 at 13:39 UTC ( #863788=note: print w/replies, xml ) Need Help??

in reply to Script/module formatting gotcha

I use this form quite often... my ($val) = () = something; I also use $this->{key} = my $val = 7;; it's not a bug. The assignment has a value of the rvalue. Neat!! If you understand this, I don't understand the question... What if I wanted to do this?
$this->{key} = # this is an important note about the next assignment my $val = blarg();
Should I have to then tell critic to ## no critic that?

Replies are listed 'Best First'.
Re^2: Script/module formatting gotcha
by morgon (Curate) on Oct 06, 2010 at 14:01 UTC
    The problem is not that the construction as such is problematic, but that the format of the source-code makes it had to see immediately what is happening (at least that is how I understand the question).

    And I am afreid that neither perltidy nor perlcritic would have helped a lot here.

    But perl -MO=Deparse <your script> would have.

Re^2: Script/module formatting gotcha
by mjscott2702 (Pilgrim) on Oct 06, 2010 at 13:52 UTC
    It's not the construct of assigning an assignment to a variable that I am questioning here, I too use this all the time.

    The source of my confusion were the hundreds of comment lines between the left and right-hand sides. IMHO, this is a way of making the code more unreadable - yes comments can do that! In your example (which, to be fair has only a single comment line, and is less likely to be confusing), I think it would be clearer to write:

    $this->{key} = my $val = blarg(); # this is an important note about the previous +assignment

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://863788]
erix just did a 12 km-run. Slow, but unstoppable!
[choroba]: My recent record is 10km in 1 hour :)
[perldigious]: Nice erix... perldigious' legs are so sore from portaging his kayak from place to place last weekend he can barely hobble 12m. :-)
[erix]: you're faster than me then :)
[erix]: well, at the moment, that is :)
[erix]: I should lose some weight although I keep telling myself that I'm doing extra training by lugging it along

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (9)
As of 2017-05-24 12:40 GMT
Find Nodes?
    Voting Booth?