'lo

Stray Toaster mwk at stray-toaster.co.uk
Mon Aug 27 11:52:33 CDT 2001


On Mon, Aug 27, 2001 at 05:39:21PM +0100, Tony Bowden wrote:
> On Mon, Aug 27, 2001 at 05:12:53PM +0100, Stray Toaster wrote:
> > my $next = $id + 4;
> > $next = 1 if ($next > @pics);
> > my $pic = $id ? $id : 1;
> > $pic = 1 if ($pic > @pics);
> > my $last_pic = $pic + 3;
> 
> I really hate this bit of logic.
> 
> I haven't a clue from looking at it what it does... and there are far
> too many magic numbers.

The magic number is 20. As that is the number of pics my digicam holds,
all of which are thumped onto a pics directory in my site. Then this
will display four on a page.

next being the next series of pics. (I have a script that names all the
images files numerically, following on from the biggest one that exists
already. Now *that* is a nasty piece of code.)

So if we are going to try and display a picture which doesn't exist,
bigger than the current biggest (which is the size of the array) then we
just send 'em back to the first page. There is also a bit of simple
anti-url hacking in there....

OK, I never said it was pretty, merely an example. And it does what I
want it to do, without throwing errors, and to me, that was what
mattered. (Pragmatist, from that test that we did when....errr...ignore
that, it makes no sense.)

perl, for all its fantastic-ness, allows cheap and nasty and quick
coding. Which is what this is.

m. who is no longer defensive over his code!



More information about the Belfast-pm mailing list