Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Re: I don't use printf enough

by tilly (Archbishop)
on Oct 25, 2003 at 04:46 UTC ( #302024=note: print w/ replies, xml ) Need Help??


in reply to Re: I don't use printf enough
in thread I don't use printf enough

I'm amazed.

I've long seen @{[stuff]} used for interpolation, but that saves only one character over interpolation (5 vs 6 chars), is unclear, and puts stuff into the wrong context.

By contrast what you've pointed out takes 4 characters, is unclear, but puts things in the right context. However it is a bit fragile.

I wonder why I haven't seen this pointed out before?

I'll definitely be remembering this, if for no reason than golf. But while I prefer it to the @{[...]} interpolation method, I still prefer concatenation over both.

UPDATE: Reminder to self, always test assumptions...


Comment on Re: Re: I don't use printf enough
Select or Download Code
Re: Re: Re: I don't use printf enough
by sauoq (Abbot) on Oct 25, 2003 at 08:14 UTC

    I'm not sure I understand your comments about @{[ $o->m() ]} putting things in the "wrong" context and ${\ $o->m() } putting things in the "right" context. The method is called in list context in both cases, right? What am I missing?

    I thought, that if you needed scalar context, you had to use scalar(). Perhaps ~~ if you are golfing and can get away with it. (I.e. your method isn't returning a reference or a floating point number.)

    Heh . . . ${\~~$o->m} . . . Ick! :-)

    Edit: Added the text "or a floating point number."

    -sauoq
    "My two cents aren't worth a dime.";
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (6)
As of 2014-07-11 23:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (236 votes), past polls