LPM: Silly string question
mandrews at bit0.com
Sat Dec 11 00:08:36 CST 1999
OK, following in the spirit of "There's More Than One Way To Do It",
and because it's late and I'm feeling silly:
my @array = ($width, "x", $height);
print join ("", @array) . "\n";
OK, not the most efficient way, but it's mostly readable. :-)
Mike Andrews (MA12) * mandrews at dcr.net * http://www.bit0.com/
VP, sysadmin, & network guy, Digital Crescent Inc, Frankfort KY
Internet services for Frankfort, Lawrenceburg, Owenton, & Shelbyville
"Don't sweat the petty things, and don't pet the sweaty things."
On Fri, 10 Dec 1999, John Soward wrote:
> 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:
More information about the Lexington-pm