LPM: Silly string question

Rich Bowen rbowen at rcbowen.com
Fri Dec 10 14:45:07 CST 1999


David Hempy wrote:
> 
> Okay, I want to print the size of an image, so I write:
> 
>         print "Size: $width x $height.\n";
> 
> ...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?
> 
> Lazily yours,
> -dave  ;-)

I tried the following:

perl -e '$foo = "one"; $bar="two"; print "${foo}X${bar}\n";'
oneXtwo

It reduces your total character count, but if you are counting shift, it
increases your key strokes.

One could also do:

perl -e '$foo = "one"; $bar="two"; print "${foo}X$bar\n";'
oneXtwo

Which does in fact reduce keystrokes, but looks a little less symmetric.

Rich
-- 
http://www.ApacheUnleashed.com/
Lexington Perl Mongers - http://lexington.pm.org/
PGP Key - http://www.rcbowen.com/pgp.txt



More information about the Lexington-pm mailing list