LPM: Silly string question

John Soward soward at uky.edu
Fri Dec 10 15:32:49 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?
> 
Well, since readability obviously isn't an issue, just change the
variable names to w and h and you've save 9 characters before you even
get started. OTOH, you could use printf and wind up with a slightly
easier to read, but still 7 character longer than desired, line of code.

printf "Size: %dx%d.\n",$height,$width;
-- 
      John Soward        University of Kentucky Technical Services
e:soward at uky.edu p:(606)257-2900 f:(606)323-1978 w:
http://neworder.cc.uky.edu/



More information about the Lexington-pm mailing list