in reply to Re: Re: Re: Web Site Mapper
in thread Web Site Mapper

We're probably not going to come to an agreement on this.

Note that a lot of people are still using perl 5.005 (constant.pm was first part of 5.6.0), and it wasn't that long ago that Debian and other GNU/Linux distros started installing something a little more recent by default. IIRC, some FreeBSD system scripts won't run on a more recent perl (this may have changed). So there are still a signifcant number of people out there that aren't even on 5.6.

When I'm coding on my main job, I use newer features of the language without a care, because I know we run a more recent version of perl. However, this script was meant for public consumption, which means avoiding newer things if possible (admittedly, I should also have used -w instead of use warnings).

Additional clarity can be gained with a simple # Constants comment above the subroutines in question. I didn't do this in the above code, but it wouldn't hurt.

----
: () { :|:& };:

Note: All code is untested, unless otherwise stated

Replies are listed 'Best First'.
Re:x5 Web Site Mapper (perl, use constant on FreeBSD)
by grinder (Bishop) on Feb 16, 2004 at 21:55 UTC
    constant.pm was first part of 5.6.0

    Not true!

    % /usr/bin/perl -v This is perl, version 5.005_03 built for i386-freebsd Copyright 1987-1999, Larry Wall [...] % cat c1 #! /usr/bin/perl -wl use strict; use constant C => 1; use constant A => [qw/a b/]; use constant H => {qw/a b/}; print C; print A; print A->[0]; print H; print H->{a}; % /usr/bin/perl c1 1 ARRAY(0x8057c18) a HASH(0x8057c3c) b

    Prior to 5.005_03, constant hashes and arrays didn't work so well, but scalars did. I think scalar constants go all the way back to 5.000 (perhaps you've been tricked by the use 5.006_00 in the source code of later releases)?

    FreeBSD 5.2 ships with 5.6.1, and I think 4.9 does as well.