Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: A simple question that can't be asked

by sundialsvc4 (Abbot)
on Oct 27, 2017 at 22:00 UTC ( #1202208=note: print w/replies, xml ) Need Help??


in reply to A simple question that can't be asked

print "My answer is \"\_" . $v1 . " _" . $v2 . "\"\n";

... Gee, that was easy ...

Please, in your quest to find the clever, please do not overlook the obvious; the pedantic.   Because, in the coming decades(!) where your source-code will still be in service, your cleverness is destined to be pored-over by an unpredictable succession of people who have to patch it.   The big-fear on their mind is that maybe your “clever™” source-code does something that they don’t immediately see, such that their patch will fail.   Be kind to them ...

N.B.: A key take-away of my proffered solution is that it is “patchable.”   It specifically does not rely upon side-effects of Perl string-interpolation which might have been true at the time that the original source-code (string) was originally written, but that might not stand the test of time ... that might not predictably(!) stand any future alterations to that string.   It does so by writing the statement in such a way that it does not rely at all upon string interpolation, except for the necessary resolution of backslash-escape characters.   Future modifications to this source-code statement, if made in a similar spirit, will remain similarly durable.

  • Comment on Re: A simple question that can't be asked

Replies are listed 'Best First'.
Re^2: A simple question that can't be asked
by eyepopslikeamosquito (Chancellor) on Oct 27, 2017 at 23:42 UTC

    Please, in your quest to find the pedantic, please do not overlook the correct. Because, in the coming decades(!) where your answer will still be in service, your foolishness is destined to be pored-over by an unpredictable succession of people who have to decipher it. The big-fear on their mind is that somewhere amid your “extravagant typography™”, “stylistic devices®”, “flowery analogies©”, and “ ‘unnecessary’ «quotes»∞”, there may lie a grain of truth. Be kind to them ...

    N.B.: A key take-away of your proferred solution is that your source-code statement is not more “patchable” nor more “durable” than the earlier proferred answers ... and contains an incorrect(!) leading space in " _".

      G'day eyepopslikeamosquito,

      ++ Marvellous paraphrasing: most impressive.

      '... and contains an incorrect(!) leading space in " _".'

      Given that he's requested pedantry not be overlooked, I'll just add:

      • ... and is missing the final underscore
      • ... and pointlessly and confusingly escapes the first underscore
      • ... and uses the wrong case for the first character
      • ... and, most importantly, is the only piece of code, in this entire thread, whose purpose and intent is not immediately obvious.
      $ perl -e 'my ($v1, $v2) = qw{A B}; print "My answer is \"\_" . $v1 . +" _" . $v2 . "\"\n";' My answer is "_A _B"

      Unfortunately, I can only downvote it once.

      — Ken

Re^2: A simple question that can't be asked
by shawnhcorey (Friar) on Oct 28, 2017 at 14:06 UTC
    say join( q{}, q{my answer is "_}, $v1, q{_}, $v2, q{_"} );

    TIMTOWTDI (There Is More Than One Way To Do It).

Re^2: A simple question that can't be asked
by LanX (Archbishop) on Oct 28, 2017 at 03:49 UTC
Re^2: A simple question that can't be asked
by karlgoethebier (Monsignor) on Oct 28, 2017 at 10:30 UTC
    "...it is “patchable.”"

    And i abandon all hope.

    «The Crux of the Biscuit is the Apostrophe»

    perl -MCrypt::CBC -E 'say Crypt::CBC->new(-key=>'kgb',-cipher=>"Blowfish")->decrypt_hex($ENV{KARL});'Help

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1202208]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (8)
As of 2019-07-18 09:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?