Home > Archive > PERL Beginners > April 2007 > Environment variable
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Environment variable
|
|
| Klaus Jantzen 2007-04-23, 7:58 am |
| I learned that in order to pass several directories one has to write
use lib qw/dir1 ... dirn/
I would like to pass the list from a bash script via an environment
variable such as
use lib $ENV{VAR}
where VAR is set in the bash script depending on some options.
My question:
How do I set the variable in the bash script?
So far I use
VAR="dir1 ... dirn"
export $VAR
but then the content of the variable is interpreted as a single string
and not a a list of
strings as required by lib.
Is it possible to define in bash a list of strings?
Any help is appreciated.
--
K. Jantzen
| |
| Jeff Pang 2007-04-23, 7:58 am |
| > My question:
> How do I set the variable in the bash script?
> So far I use
> VAR="dir1 ... dirn"
> export $VAR
> but then the content of the variable is interpreted as a single string
> and not a a list of
> strings as required by lib.
> Is it possible to define in bash a list of strings?
Hello,
Do it like this way,you'll get it.
export LIBS=dir0:dir1:dir2
perl -Mstrict -e 'my @libs = split/:/,$ENV{LIBS};use lib @libs'
--
Chinese Practical Mod_perl book online
http://home.arcor.de/jeffpang/mod_perl/
| |
| yaron@kahanovitch.com 2007-04-23, 7:58 am |
| How about
use lib split("\s+",$ENV{PATH});
Yaron Kahanovitch
----- Original Message -----
From: "Klaus Jantzen" <k.d.jantzen@t-online.de>
To: "Beginner Perl" <beginners@perl.org>
Sent: 10:35:39 (GMT+0200) Asia/Jerusalem =D7=99=D7=95=D7=9D =D7=A9=D7=A0=D7=
=99 23 =D7=90=D7=A4=D7=A8=D7=99=D7=9C 2007
Subject: Environment variable
I learned that in order to pass several directories one has to write
use lib qw/dir1 ... dirn/
I would like to pass the list from a bash script via an environment=20
variable such as
use lib $ENV{VAR}
where VAR is set in the bash script depending on some options.
My question:
How do I set the variable in the bash script?
So far I use
VAR=3D"dir1 ... dirn"
export $VAR
but then the content of the variable is interpreted as a single string=20
and not a a list of
strings as required by lib.
Is it possible to define in bash a list of strings?
Any help is appreciated.
--=20
K. Jantzen
--=20
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/
| |
| Klaus Jantzen 2007-04-23, 7:58 am |
| Jeff Pang wrote:
>
>
>
> Hello,
>
> Do it like this way,you'll get it.
>
> export LIBS=dir0:dir1:dir2
> perl -Mstrict -e 'my @libs = split/:/,$ENV{LIBS};use lib @libs'
>
>
>
Thank you for the help.
Both suggestions in the form
"sub lib split /\s+/,$ENV{VAR}" or
"sub lib split /:/,$ENV{VAR}"
achieve the expected result.
--
K. Jantzen
|
|
|
|
|