Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Env variables

by mskvimal (Initiate)
on Mar 21, 2008 at 03:20 UTC ( [id://675368]=perlquestion: print w/replies, xml ) Need Help??

mskvimal has asked for the wisdom of the Perl Monks concerning the following question:

can some one help me with a snippet to set env path from perl to cmd prompt.

I used the following option but its not working

$IM_ROOT and $IM_DATA cmd arg from perl
use Env::C; #Line 8 get ath this line Env::C::setenv($TC_ROOT, "$IM_ROOT", [$override]); Env::C::setenv($TC_DATA, "$IM_DATA", [$override]);
Error:
BEGIN failed--compilation aborted at C:\Apps\TCRoot\web\htdocs\cgi-bin +\testENV.pl line 8.

Replies are listed 'Best First'.
Re: Env variables (/first/ error)
by tye (Sage) on Mar 21, 2008 at 05:27 UTC
    Error: BEGIN failed--compilation aborted

    An often important general rule is that the first error message is usually the one that you want to pay attention to. The error message you quoted above is not the first error message you got. It is a follow-on error message that notes a consequence of the previous error and one that is particularly unenlightening here.

    Please look at the first error message and it'd probably be good to reply to your node with the exact text of that first error message so the rest of us don't have to guess at what error you got (though, my guess is that you didn't declare the $override variable while you were smart enough to use strict, but that is just a guess -- further, I guess that you should just drop the [$override]s from your code).

    - tye        

Re: Env variables
by hipowls (Curate) on Mar 21, 2008 at 03:43 UTC

    You need to wrap your code in <code> and </code> tags. The characters [ and ] are special to perl monks and can't be put as literal text in your post. You should also use <p> and </p> tags around paragraphs.

    At a guess you have cut and pasted this code from the documentation

    Env::C::setenv($key, $value, [$override]);
    where [$override] is intended to be read as an optional parameter.

    If you fix your post with code tags and an explanation of what your are trying to achieve you will get a better response. Please read How do I post a question effectively?.

Re: Env variables
by kyle (Abbot) on Mar 21, 2008 at 04:30 UTC
Re: Env variables
by hipowls (Curate) on Mar 22, 2008 at 05:04 UTC

    Thanks for fixing the format of your post++. As tye said it looks like Env::C is not installed but we'd need to see the full error message to be sure.

    Are you sure that you need to use this module? As the documentation says

    Sometimes Perl invokes modules with underlaying C APIs which rely on certain environment variables to be set, if these variables are set in Perl and the glue code doesn't worry to set them on the C level, these variables might not be seen by the C level. This module shows what really the C level sees.
    Most of the time setting %ENV will be sufficient.

    Some examples

    $ENV{IM_ROOT} = $TC_ROOT; # set IM_ROOT $ENV{IM_DATA} |= $TC_DATA; # set IM_DATA if not already set system qw(program -switch argument); # program sees new values of IM_ +ROOT and IM_DATA { # this value of IM_DATA is only seen while this block is executing local $ENV{IM_DATA} = $TC_DATA; system qw(program -switch argument); }
    These variables will be seen by any child processes spawned by your program and most modules.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (8)
As of 2024-04-19 08:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found