Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^7: A short whishlist of Perl5 improvements leaping to Perl7 (Python TMTOWTDI)

by eyepopslikeamosquito (Archbishop)
on Nov 26, 2020 at 06:46 UTC ( [id://11124249]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    "Dear $name"              # Perl and PHP
    "Dear %s" % expr          # Python and Ruby % printf-like operator
    ...
    "Dear "+`expr`            # Python backticks (TMTOWTDI)
    "Dear #{expr}"            # Ruby string interpolation
    "Dear @{[expr]}"          # Perl "Baby Cart" string interpolation
    
  2. or download this
    5 * "X"    also produces "XXXXX" in Python! TMTOWTDI! :)
    5 * "X"    ... but not in Ruby (won't compile: type error)
    5 x "X"    ... or Perl (produces empty string)
    
  3. or download this
    $"x(318%$_/9)        Perl
    " "*(318%i/9)        Ruby
    318%i/9*" "          Python
    
  4. or download this
    n=99
    z=lambda:`n or 99`+" bottle"+"s of beer on the wall"[n==1:]
    while n:y=z();n-=1;print"%s, %s.\n"*2%(y,y[:-12],n and"Take one down a
    +nd pass it around"or"Go to the store and buy some more",z())
    
  5. or download this
    n and"Take one down and pass it around"or"Go to the store and buy some
    + more"
    
  6. or download this
    "Take"if n else"Go to"
    (n>0)*"Take"or"Go to"
    ...
    ("Go to","Take")[n>0]
    n and"Take"or"Go to"
    "GToa kteo"[n>0::2]          # "Slice and Dice" wins this golf!
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2024-04-23 20:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found