in reply to Trying to be stricter...

Disclaimer I don't pretend to give 'accepted wisdom' here, but from my own experience, I'd suggest turning your library of code into a full-blown module that uses the standard Exporter methods to export its variables (including subroutines). Then you just use that module.

It's a bit of work (but then, anything you'll do to retrofit things will be a bit of work, some more than others). This method allows you to only export those variables you want, rather than messing up your namespaces, and it will be relatively easier to understand later on, plus you can distribute your module to others who might find it useful.

Plus, you'll learn something in the process. I know I did =)

HTH

perl -e 'print "How sweet does a rose smell? "; chomp ($n = <STDIN>); +$rose = "smells sweet to degree $n"; *other_name = *rose; print "$oth +er_name\n"'

Replies are listed 'Best First'.
Re: Re: Trying to be stricter...
by stephen (Priest) on Jun 01, 2001 at 04:15 UTC
    I'd agree with that, but add that it's generally a really good idea to declare your constants as constants, not as variables. Or, to coin a phrase, "If something isn't supposed to vary, why make it a variable?" So instead of having
    $Foo = 'bar';
    I'd have:
    use Exporter; @ISA = qw(Exporter); @EXPORT_OK = qw(FOO); use constant FOO => 'bar';
    That way, you won't accidentally alter the value of FOO elsewhere in the program. Plus, it'll be interpolated as a literal, so you might actually gain some speed.

    stephen