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

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
Replies are listed 'Best First'.
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."

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

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (9)
As of 2015-12-01 03:59 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (792 votes), past polls