Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Re^2: Strictly nested sub warnings

by pobocks (Chaplain)
on Oct 06, 2010 at 04:09 UTC ( #863717=note: print w/replies, xml ) Need Help??

in reply to Re: Strictly nested sub warnings
in thread Strictly nested sub warnings

Out of curiousity, why #5? I don't question that it's the case (you know better than me by job lots), I just wondered what the reason was.

for(split(" ","tsuJ rehtonA lreP rekcaH")){print reverse . " "}print "\b.\n";

Replies are listed 'Best First'.
Re^3: Strictly nested sub warnings
by GrandFather (Sage) on Oct 06, 2010 at 04:42 UTC

    It's fairly minor, but using concatenation when you could use interpolation instead tends to obscure the result you are aiming for. Compare the following two print statements:

    use strict; use warnings; my $tsuJ = 'tsuJ'; my $rehtonA = 'rehtonA'; my $lreP = 'lreP'; my $rekcaH = "\nrekcaH"; print join ' ', map {scalar reverse} split / /, $tsuJ . ' ' . $rehtonA + . ' ' . $lreP . ' ' . $rekcaH; print join ' ', map {scalar reverse} split / /, "$tsuJ $rehtonA $lreP +$rekcaH";
    True laziness is hard work
Re^3: Strictly nested sub warnings
by ikegami (Pope) on Oct 06, 2010 at 04:42 UTC
    Especially if you're joining lots of vars with short strings, concatenation can leave you drowning in symbols.
      For short variables I agree 100%.

      For more complex variables, I tend to go back to concatenation to make sure I get what I want.

      print "Guess what you get: $hashref->{$lookup1[$i]}->{$lookup2[$i]}\n" +;

      Also, with syntax highlighting, punctuation actually makes the code more readable than interpolation IMO.

      -- Time flies when you don't know what you're doing

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (9)
As of 2016-10-26 08:42 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (337 votes). Check out past polls.