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

Re^3: Convert Shell script to Perl

by akrrs7 (Acolyte)
on Oct 10, 2011 at 15:26 UTC ( #930666=note: print w/replies, xml ) Need Help??


in reply to Re^2: Convert Shell script to Perl
in thread Convert Shell script to Perl

This is the code:
use strict; use warnings; $ENV {'LIBDIR'}='$MY_XALANHOME/bin'; $ENV {'LOCALCLASSPATH'}='$ENV{LIBDIR}:/xalan.jar'; $ENV {'LOCALCLASSPATH'}='$ENV{LOCALCLASSPATH}:$ENV{LIBDIR}/xml-apis.ja +r'; $ENV {'LOCALCLASSPATH'}='$ENV{LOCALCLASSPATH}:$ENV{LIBDIR}/xercesImpl. +jar';
When I run the perl program from the command line using - perl abc.pl - I don't get any error messages. When I run the following command from the commandline:
perl $ENV{'LIBDIR'}='C:\SOMEFOLDER';
I get a message saying - can't open perl script "$ENV": no such file or directory. I would've expected to create a new environment variable called LIBDIR with the c:\somefolder as the value ? Thanks

Replies are listed 'Best First'.
Re^4: Convert Shell script to Perl
by Utilitarian (Vicar) on Oct 10, 2011 at 15:43 UTC
    Two things, you need to tell the Perl interpreter to execute the code rather than look for a file of that name and the environment variables will not be set int the parent process (your shell) only in the Perl process and its children.

    So while perl -e "$ENV{LIBDIR'}='C:\SOMEFOLDER';" would create the varable, it would cease to exist when Perl exited.

    print "Good ",qw(night morning afternoon evening)[(localtime)[2]/6]," fellow monks."

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://930666]
help
Chatterbox?
[Corion]: choroba: Yeah, I think that would be the good solution
[LanX]: I suspect the first string which comes from the DB ...
[LanX]: ... but this part is already in production for a year now
[Corion]: LanX: The "good" approach here would be to use the appropriate DBI parameters to make the driver decode strings properly. But that will have a ripple-on effect of messing up all the places where manual decoding happens ;)
[LanX]: which means albeit being broken UTF8 it'll be handled correctly
[LanX]: and the problem only occurs since we changed the emails to base64
[LanX]: my main problem will be to cnvince my colleagues that our productive code is broken oO ... so in the end I will just make a workaround :-/
LanX hates UTF8 for causing knots in his brain and stomach
[Corion]: LanX: Yes, that's the main problem - you have lots (and lots) of workarounds in various places and stages of the processing, and to clean that mess up requires action across the complete codebase. And it's almost impossible to do it piece-by-piece

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (11)
As of 2017-01-16 14:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you watch meteor showers?




    Results (150 votes). Check out past polls.