At 11:26 AM 08.22.2001 -0400, Bob Showalter wrote:
> > -----Original Message-----
> > From: Kingsbury, Michael [mailto:[EMAIL PROTECTED]]
> > Sent: Wednesday, August 22, 2001 11:07 AM
> > To: '[EMAIL PROTECTED]'
> > Subject: How to reference env variables.
> >
> >
> > When running a command such as :
> >
> > `ls -la /some/directory`
> >
> > there is an envirornment variable called !EXITCODE that I want to
> > reference. I already have Use Env in place, but how do I
> > keep perl from
> > gagging on the bang in the variable name??
>
>Based on a cursory glance at Env.pm, it appears that it will skip
>any names in the environment that dont match [A-Za-z_].
Theoretically you shouldn't be using any environment tokens with special
characters in them anyway since the shell can and will misinterpret them at
the most un useful times. The '!' is a great example of this since bash
will go crazy on it as well as many other shells. In fact, you should
really find out what is gagging, the Perl script or the shell. You're
probably right that it is the Perl interpreter but I'd double check to make
sure. It looks like the c shell is innocuous to the '!' based on HP
example below.
I have to agree with the suggestion made here too, that you need to be
specific about what your env var !EXITCODE does. Perhaps there is a Unix
mechanism or Perl mechanism already in place that will do what you are
attempting (seem to anyway) do.
- Jim
>You could get at it through the regular %ENV hash:
>
> $ENV{'!EXITCODE'}
>
>This command works on my (HPUX) system:
>
> $ env !EXITCODE=hello perl -e 'print $ENV{q[!EXITCODE]}, "\n"'
> hello
>
>Is this variable some artifact of your shell? Are you wanting to
>test it following the ls backticks? If so, this isn't going to
>work. The shell/ls will be executed in a child process, and the
>child cannot affect the parent's environment. If you just want
>the exit status from the backtics, you can use Perl's regular
>$? variable. Or maybe I'm misunderstanding the whole issue.
>(Wouldn't be the first time).
>
>--
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
- Jim
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
http://www.perlmonks.org/index.pl?node_id=67861&lastnode_id=67861
-----BEGIN PERL GEEK CODE BLOCK----- ------BEGIN GEEK CODE BLOCK------
Version: 0.01 Version: 3.12
P++>*@$c?P6?R+++>++++@$M GIT/CM/J d++(--) s++:++ a-
>++++$O!MA->++++E!> PU-->+++BD C++++(+) UB++++$L++++$S++++$
$C-@D!>++++(-)$S++++@$X?WP+>++++MO!>+++ P++(+)>+++++ L+++(++++)>+++++$ !E*
+PP+++>++++n-CO?PO!o >++++G W++(+++) N+ o !K w--- PS---(-)@ PE
>*(!)$A-->++++@$Ee---(-)Ev++uL++>*@$uB+ Y+>+++ PGP t+(+++)>+++@ 5- X++ R@
>*@$uS+>*@$uH+uo+w-@$m! tv+ b? DI-(+++) D+++(++) G(++++)
------END PERL GEEK CODE BLOCK------ ------END GEEK CODE BLOCK------
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]