Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^3: On bad habits

by jeffa (Chancellor)
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
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 avoiding work at the Monastery: (5)
As of 2014-08-23 07:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (172 votes), past polls