Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

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 (Saint) 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 (Patriarch) 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
Domain Nodelet?
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 wandering the Monastery: (5)
As of 2022-12-06 00:47 GMT
Find Nodes?
    Voting Booth?

    No recent polls found