in reply to Re: I know this code could be better...
in thread I know this code could be better...

Instead of
sub LINKS { return 'h:\perl scripts\links.txt'; }
you're better off to be more Perlish with constant.pm:
use constant LINKS => 'h:\perl scripts\links.txt';

xoxo,
Andy

%_=split/;/,".;;n;u;e;ot;t;her;c; ".   #   Andy Lester
'Perl ;@; a;a;j;m;er;y;t;p;n;d;s;o;'.  #   http://petdance.com
"hack";print map delete$_{$_},split//,q<   andy@petdance.com   >

Replies are listed 'Best First'.
Re: Re: Re: I know this code could be better...
by jreades (Friar) on Jun 21, 2001 at 01:16 UTC

    Yes, but consider a change needing to be made down the line:

    Q: "Hey petdance we're porting this script to Unix, can you make it run there too?"

    A: "Sure, I'll just change the constant."

    Q: "Hey what did you change in that script so that now it doesn't work on NT anymore?"

    A: "Hmmmmm"

    Ok, so the example is a stretch, but imagine the solution using a sub instead of a constant.

    sub LINKS { if (sub_to_determine_OS() =~ /(Unix|Linux)/) { return "/u/jreades/links.txt"; } else { return "U:\jreades\nt_links.txt"; } }

    And all of that requires exactly no changes to the rest of your application.

    Yes, it is paranoid, but that doesn't mean they're not out to get you.