[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] gifToHtml one-liner mystery



hello.

I am trying to get one of the Perl one liners from TPJ#11 to work on a Mac.
the source is almost unreadable (to me - black on grey could be construed
as less than readble in my opinion) in the magazine, and isn't available
online - yet. so...what I have is...

-----------code-----------

#!/usr/bin/perl

@theGifs = <*.gif>;
use GD;
$f = 'ffffff';
$T = table;
sub p{print @_}
	p"<body bgcolor=$f>";
	for(@theGifs)
		{
			open*G,$_ or(warn("$_: $!")&&next);
			$g=GD::Image->newFromGif(G) || (warn$_, ": GD
Error"and next);

	@c=map{$_!=$g->transparent?sprintf'#'.('%.2x'x3),$g->rgb($_):$f}0..$g->colorsTo
tal;
			p"<$T border=0 cellpadding=0 cellspacing=0>";
			($x,$y)=$g->getBounds;
				for $j(0..$y)
					{p"<tr>";
						for($i=0; $i<x; $i++)
						{$s=1;
$s++&&$i++while($i+1<$x&&$g->getPixel($i+1,$j)==$g->getPixel($i,$j));
					p"<td bgcolor=",
$c[$g->getPixel($i,$j)]," colspan=$s>&nbsp"}}p"</$T>"}

-----end code----------------

which compiles fine, but then prints out:

<body bgcolor=ffffff><table border=0 cellpadding=0
cellspacing=0><tr><tr><tr><tr><tr><tr><tr><tr><tr><tr><tr><tr><tr><tr><tr><tr><t
r><tr><tr><tr><tr><tr><tr><tr><tr><tr><tr><tr><tr><tr><tr><tr><tr><tr><tr><tr> 
(ad infinitum)

no matter which gif I feed into the process. what subtle or gross error am
I making here?

anyone?

andrew mckenzie



***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch