在Perl来砸变量返回两个值 [英] return two values from perl to bash variables

查看:182
本文介绍了在Perl来砸变量返回两个值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我打电话一个perl脚本来计算bash脚本的大小和变化。有没有办法在bash这两个值返回分离变量中,比如$ SIZE和$ VAR。只有懂得回报一个值。

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.

推荐答案

,您可以从Perl脚本打印变量,分离,比方说,空间,然后从庆典阅读:

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";

#!/bin/bash
read SIZE VAR <<<$(my_perl_script)
echo size: $SIZE var: $VAR

这篇关于在Perl来砸变量返回两个值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆