Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: How to include a string immediately after a variable in a double-quoted string

by jeffa (Bishop)
on Nov 20, 2015 at 21:44 UTC ( [id://1148266]=note: print w/replies, xml ) Need Help??


in reply to How to include a string immediately after a variable in a double-quoted string

You can also use printf/sprintf to keep your data separated from the "presentation":

printf "The maximum number of %sevents on %s occurred %d times; it was + %d.\n", $type, $date, $maxtimes, $max, ;

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)
  • Comment on Re: How to include a string immediately after a variable in a double-quoted string
  • Download Code

Replies are listed 'Best First'.
Re^2: How to include a string immediately after a variable in a double-quoted string
by stevieb (Canon) on Nov 20, 2015 at 22:54 UTC

    I always forget about printf in Perl. In Python (3+), there's no interpolation, so I'd have to do print("Hello {}, how are you {}".format(name, today)).

    No matter what you want to print with variables, you have to do it this way (at least for a normal print statement), including all the parens and cruft.

    I've taken perl interpolation for granted me thinks ;)

Re^2: How to include a string immediately after a variable in a double-quoted string
by msh210 (Monk) on Nov 22, 2015 at 04:57 UTC

    Thank you!

    print map chr($w+=$_),74,43,-2,1,-84,65,13,1,5,-12,-3,13,-82,48,21,13,-6,-76,78,-9,18,-21,7,-4,-57,-34#stackoverflow.com/q/10858682

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (2)
As of 2024-04-19 01:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found