Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
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

Replies are listed 'Best First'.
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?
[Discipulus]: DBI::CSV + utf8 = BOO?M
[erix]: in extremis we tend to forget stuff ;)
[ELISHEVA]: \Disciplus : lol
[Discipulus]: and ELISHEVA we waait one your post since ~2years... ;=)
[ELISHEVA]: has it really been that long?
[Discipulus]: it seems..
[Discipulus]: more: just one thread in the last ~5 years
[Discipulus]: but Dumas is waiting for me in the bed.. luckly as book author.. see you!
[ELISHEVA]: Sleep well!
[ELISHEVA]: Or read well

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (9)
As of 2017-05-28 20:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?