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

Version 1.0 of constant came out in 1997 so it's not that new :)

Yes, switching from sub XYZ() to constant requires code changes. But for new development, it's a little clearer the intentions of what your sub is there for and that you aren't insane.

My version of constant.pm has about 100 lines of perl, with warnings::register using about 25. Not too much for some code clarity if you ask me.


Play that funky music white boy..

Replies are listed 'Best First'.
Re: Re: Re: Re: Web Site Mapper
by hardburn (Abbot) on Feb 16, 2004 at 17:07 UTC

    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

      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.