Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: I don't use printf enough

by antirice (Priest)
on Oct 22, 2003 at 17:55 UTC ( #301299=note: print w/ replies, xml ) Need Help??


in reply to I don't use printf enough

TIMTOWTDI

print "text text ${\ $obj->method1() } more text ${\ $obj->method2() } + blah blah ${\ $obj->method3() }\n";

:)

antirice    
The first rule of Perl club is - use Perl
The
ith rule of Perl club is - follow rule i - 1 for i > 1


Comment on Re: I don't use printf enough
Download Code
Re: Re: I don't use printf enough
by dragonchild (Archbishop) on Oct 22, 2003 at 18:01 UTC
    Ignoring any sort of performance issues, I find that almost impossible to read. *shrugs* TMTOWTDI ... I guess ...

    ------
    We are the carpenters and bricklayers of the Information Age.

    The idea is a little like C++ templates, except not quite so brain-meltingly complicated. -- TheDamian, Exegesis 6

    ... strings and arrays will suffice. As they are easily available as native data types in any sane language, ... - blokhead, speaking on evolutionary algorithms

    Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.

      I agree. I brought it up merely as interesting syntax to do the same thing.

      antirice    
      The first rule of Perl club is - use Perl
      The
      ith rule of Perl club is - follow rule i - 1 for i > 1

Re: Re: I don't use printf enough
by tilly (Archbishop) on Oct 25, 2003 at 04:46 UTC
    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...

      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://301299]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (16)
As of 2015-07-01 16:04 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 (9 votes), past polls