in reply to Re^3: using map
in thread using map

If the format contains no %specifiers, then just what is in the template gets output.

And so printf $_ acts exactly like print $_.

Very clever... until $_ happens to contain something that looks like a printf specifier and it comes back to bite you.

Of course, say ought to be a simple alternative to -l, but a) they made it so darn inconvenient to use

For one-liners, say is actually very convenient to use. Just replace "-e" with "-E".

perl -E"say q(Hello world)"
perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

Replies are listed 'Best First'.
Re^5: using map
by jwkrahn (Abbot) on May 06, 2012 at 07:21 UTC
    And so printf $_ acts exactly like print $_.

    Not exactly.    printf still has to parse $_ looking for format specifiers.    And print is affected by the $\ and $, variables while printf is not.

      That's what I just said, isn't it?

      perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'
Re^5: using map
by BrowserUk (Patriarch) on May 06, 2012 at 07:32 UTC
    until $_ happens to contain something that looks like a printf specifier

    And the millions of microwave ovens in family kitchens across the globe can act exactly like small bombs with nothing more than the addition of some plain water! But nobody suggests we should ban the use of either.

    The answer is quite simple. Don't use it where that is a possibility.

    For one-liners, say is actually very convenient to use.

    a) Yes, I know. b) Nobody was talking about one-liners.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

    The start of some sanity?