Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

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


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


The first rule of Perl club is - use Perl
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.

      The first rule of Perl club is - use Perl
      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."

      "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://301299]
[james28909]: politicians making jobs for themselves? that is absurd! we all know how hard those politicians have it, having to take millions from lobbiest while screwing over their citizens. have a little sympathy why dont ya!

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (9)
As of 2017-12-15 18:33 GMT
Find Nodes?
    Voting Booth?
    What programming language do you hate the most?

    Results (442 votes). Check out past polls.