|
Search Forums:
|
|||||||
| Forums | Register | Forum Rules | Linux and Unix Links | Man Pages | Albums | FAQ | Users | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
[SOLVED] Scope of KSH Variable in Perl?
cat test.ksh Code:
#!/usr/bin/ksh VAR="Dear Friends \n How are you? \n Have a nice day \n" export VAR echo "Inside test.ksh"; ./test.pl cat test.pl Code:
#!/usr/bin/perl print "Inside test.pl \n"; print "$VAR"; Output: Code:
./test.ksh Inside test.ksh Inside test.pl What I want to achieve is, I have a string variable (with blank spaces) in ksh. When I echo that string variable in ksh, it prints fine. BUT, I have a scenario where I would want the perl script to be able to use that string variable. How can I achieve that? ---------- Post updated at 11:35 AM ---------- Previous update was at 10:59 AM ---------- Ok, I myself got it after few tests. Here is how I do it: Instead of print "$VAR"; I use print $ENV{"VAR"}; Thanks! |
| Sponsored Links | |
|
|
|
#2
|
|||
|
|||
|
Having exported it from your your Shell script, within the Perl, invoked from same script you will find that print "$ENV{VAR}\n" is what you want. Export exports a variable into the environment and the %ENV hash is how Perl accesses them. Regards Neil
|
| Sponsored Links | ||
|
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| scope of a Variable inside shell script | vij_krr | Shell Programming and Scripting | 4 | 11-02-2009 06:37 AM |
| perl - how can we name a variable base on value of another variable | cacm1975 | Shell Programming and Scripting | 3 | 10-07-2009 10:27 AM |
| variable scope | shellwell | Shell Programming and Scripting | 3 | 07-15-2009 11:38 AM |
| scope of the variable - Naga | nagnatar | Shell Programming and Scripting | 13 | 04-27-2009 02:26 PM |
| C++ variable scope and mutexes | Corona688 | Programming | 0 | 10-05-2005 01:29 PM |
|
|