Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

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...

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 all is quiet...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2018-03-20 05:18 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (247 votes). Check out past polls.