How do I do it?
Programs communicate via STDIN/STDOUT, so the way morgon and others showed you is the way to do it
| [reply] |
OK, so you are saying that in order for me to get access to a variable that was set in perl block, I woud need to print that variable either to stdout or to a file and then read it back in the shell part of the code? Since I don't want to print into a file, then I need to print to stdout. But when morgon says:
variable=$(perl script.pl)
what is 'script.pl'? I don't have a .pl script. I only have .sh script. | [reply] [d/l] |
You cannot simply reference a Perl-variable in a shell-script.
You have to find a way to pass the *value* of the variable from Perl to the shell.
The way via command-subsitution I showed above is one way to do this.
Perl prints the value to STDOUT and the shell reads it into a shell-variable (which is different from the perl-variable).
Now if you have the perl-script directly embedded in your shell-script as a here-doc then you will have all sorts of problems properly escaping stuff, which is why I suggested above that you put all the Perl-code into a script of it's own that you can call anything you like - I called it simply "script.pl" for illustration but what you have to do is to move the perl-code from the shell-script into a perl-script file and call that file via command-substitution.
| [reply] |
Without changing the perl code to report the value somehow, there is no way. | [reply] |