Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Re: Re: Re: I know this code could be better...

by jreades (Friar)
on Jun 21, 2001 at 01:16 UTC ( #90195=note: print w/ replies, xml ) Need Help??

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

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.

Comment on Re: Re: Re: I know this code could be better...
Download Code

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://90195]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2016-02-07 04:27 GMT
Find Nodes?
    Voting Booth?

    How many photographs, souvenirs, artworks, trophies or other decorative objects are displayed in your home?

    Results (246 votes), past polls