Reputation: 2187
I am calling a perl script to calculate size and variation in bash script. Is there a way to return those two values to separated variables in bash, say $SIZE and $VAR. Only know how to return one value.
Upvotes: 1
Views: 1542
Reputation: 3597
you can only do that by evaluating perl's output e.g.:
from perl:
print "SIZE=1 VAR=blah"
then in shell script:
export `your perl script.pl`
Upvotes: 1
Reputation: 9867
Instead of returning (which is mainly used for an error/success code from the script), you can print your variables from the perl script, separated by, say, space, and then read them from bash:
#!/usr/bin/perl
$size=1;
$var=2;
print "$size $var\n";
and:
#!/bin/bash
read SIZE VAR <<<$(my_perl_script)
echo size: $SIZE var: $VAR
Upvotes: 7