in reply to assigning a perl variable in shell
You might want to reconsider your design, since embedding Perl scripts in shell scripts has a couple of tricky aspects and can make maintenance a bit less fun. The easiest might be to put your Perl script into a separate file and just run that, or even inverting the design, that is, write most of your script in Perl, and then call external commands via system or a module like IPC::System::Simple.
Having said that, two relatively easy ways to pass shell script variables into Perl: Pass the variables as arguments on the command line of perl and then in your script access them via @ARGV, or, if the variables are visible in the environment, use the %ENV hash to access them.
I'm noticing if I try to assign a variable in perl like $dog, the shell script gives me an error.
What's the error message? There is no $dog in your sample code.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: assigning a perl variable in shell
by scheidr (Novice) on Jan 13, 2015 at 20:22 UTC | |
by eyepopslikeamosquito (Archbishop) on Jan 14, 2015 at 00:31 UTC | |
by scheidr (Novice) on Jan 16, 2015 at 22:39 UTC | |
by soonix (Chancellor) on Jan 17, 2015 at 11:30 UTC | |
by RonW (Parson) on Jan 13, 2015 at 22:43 UTC | |
| A reply falls below the community's threshold of quality. You may see it by logging in. |