Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Re^2: accessing an environment variable dynamically

by JennieInMI (Acolyte)
on Jan 01, 2013 at 20:58 UTC ( #1011183=note: print w/replies, xml ) Need Help??

in reply to Re: accessing an environment variable dynamically
in thread accessing an environment variable dynamically

Thanks for the welcome.

It's pretty much just what I asked in my initial post. I need to compare two folders and find out if the content is identical. I've got a BC3 script that does that. Supposedly, it sets the %errorLevel% environment variable when it's done executing and I should be able to capture that and use that value to inform my Perl script of the success or failure of that comparison, but I'm not having a lot of sucess. Thus the questions I listed.

If this doesn't work I can parse the report generated by my BC3 script, but this SEEMED the easier option. Also, the current manual audit process specifies a BC3 comparison so I'd like to honor that. If I need to do it differently though, I think that'd be fine as long as it is accurate.

Also, I think learning how to do this correctly will be really valuable in the long run. Scripts generally tend to do a lot of interacting with the environment they run on so becoming adept at accessing and utilizing those values seems like a smart plan.

Thanks so much for being so willing to jump in and help another coder.


  • Comment on Re^2: accessing an environment variable dynamically

Replies are listed 'Best First'.
Re^3: accessing an environment variable dynamically
by Tommy (Chaplain) on Jan 01, 2013 at 21:36 UTC

    Ok, so here's what you want to do: listen to BrowserUK who is brilliant with Perl on Windows. BrowserUK is right that you need to focus on the value of $? after you run your system call. Personally, I like to dig a little deeper and avoid the shell as much as possible when running system commands, so I use IPC::Open3, for example.

    But for your project here, using the system() command or qx{} will probably serve you just fine. Read the perldoc -f system documentation, and you'll see it's quite doable.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1011183]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2018-01-19 04:38 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (215 votes). Check out past polls.