Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^3: On bad habits

by jeffa (Bishop)
on Jun 21, 2005 at 18:23 UTC ( #468777=note: print w/ replies, xml ) Need Help??


in reply to Re^2: On bad habits
in thread On bad habits

No thanks. :) If i am going to use a newline frequently, i add the -l (dash elle) run switch:

#!/usr/bin/perl -l
And then i don't need to worry about adding newlines. Uh oh ... what if i don't want to always print out a newline? Simple, just use printf.

Work smart ... not hard. ;)

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)


Comment on Re^3: On bad habits
Download Code
Replies are listed 'Best First'.
Re^4: On bad habits
by grinder (Bishop) on Jun 21, 2005 at 22:25 UTC
    what if i don't want to always print out a newline? Simple, just use printf.

    For years, I have been sitting here, railing and fuming silently against the supposed "brokenness" of printf's disrespect for -l. It's something I'd always put aside as a non-orthogonal oddity of the language.

    My anger blinded me to the possibility of using my opponent's strength to my own advantage -- a classic judo move.

    Thank-you for letting me see the error of my ways.

    jeffa++

    • another intruder with the mooring in the heart of the Perl

Re^4: On bad habits
by bart (Canon) on Jun 22, 2005 at 11:50 UTC
    If i am going to use a newline frequently, i add the -l (dash elle) run switch
    And if I want the effect locally, I set $\ (and optionally, $,) in a block, for example to print out a tab delimited text file:
    { local($\, $,) = ("\n", "\t"); print @fields; }
Re^4: On bad habits
by Xenograg (Scribe) on Jun 24, 2005 at 21:48 UTC

    I am obviously in the explicit-declaration faction.

    ++jeffa thanks for another WTDI. :)

    --- The harder I work, the luckier I get.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2015-07-31 03:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (274 votes), past polls