Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

%ENV on exotic platforms

by John M. Dlugosz (Monsignor)
on Sep 29, 2003 at 18:46 UTC ( #295067=perlquestion: print w/replies, xml ) Need Help??

John M. Dlugosz has asked for the wisdom of the Perl Monks concerning the following question:

What does %ENV do on platforms other than UNIX/DOS derivitives? Do unrelated platforms even have such a concept, or does Perl provide an emulation of some kind?

I'm asking for a matter of portability. If I want to write some "run on anything that has Perl" code, can I rely on the existance of environment variables, or do I need to provide another mechanism (e.g. config file) as well?

—John

Replies are listed 'Best First'.
Re: %ENV on exotic platforms
by Elian (Parson) on Sep 29, 2003 at 19:59 UTC
    Every platform that Perl runs on has a native structure to match %ENV. While it may be odd and complex (such as VMS' mapping of %ENV to the symbol and logical tables) it is there, and behaves as you'd expect it to behave, and can be assumed to work as it would on Unix systems.

    The interaction of the %ENV-analogue and spawned subprocesses may be interesting, that's very platform-dependent anyway, and as such is likely something you're not going to need to worry about. To keep it safe, don't use common names or abbreviations as ENV keys (such as LIB, COMMON, SRC, INCLUDE, or TMP) and try not to make the names too long (assume you've no more than 16 characters for the key and 125 characters for the value).

    Files are generally more portable, though.

Re: %ENV on exotic platforms
by jdtoronto (Prior) on Sep 29, 2003 at 19:04 UTC
    On Windows (up to XP which is my experience) the %ENV works as it does on a UNIX box. The variables just don't have the same names thats all!

    jdtoronto

Re: %ENV on exotic platforms
by waswas-fng (Curate) on Sep 29, 2003 at 20:12 UTC
    System ENV will be different across platforms, If you are trying to gather config details from user set ENV then I think a config file or command line flag would be better suited to being compatible across platforms.


    -Waswas

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://295067]
Approved by bart
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2021-09-19 09:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?