LPM: Silly string question
Steve Lane
sml at zfx.com
Fri Dec 10 14:33:06 CST 1999
David Hempy wrote:
> ...but I'd rather not have the spaces around the "x". Of course, the
> following does not work:
>
> print "Size: $widthx$height.\n";
>
> So I ended up doing this:
>
> print "Size: $width" . "x$height.\n";
>
> Which is fine and dandy, but requires seven extra keystrokes (including
> shifts). My goal in my professional life is to reduce the total number of
> keystrokes my fingers must endure. Is there some "end of identifier"
> operator or other perl magic that might fill the bill?
you're in luck, but it'll require two extra characters
(and four keystrokes):
print "Size: ${width}x$height.\n";
i'm tempted to try to explain the general rule here
(something like "braces following a variable identifier
character mean treat what's inside the braces as either
a reference or a variable name"), but i'm not exactly
sure if that's exactly correct. anyway, it works.
--
Steve Lane <sml at zfx.com>
More information about the Lexington-pm
mailing list