perl - Is it possible to call a function within qx? -
here's bit of perl code want:
$value = get_value(); $result = qx(some-shell-command $value); sub get_value { ... homecoming ... }
is possible accomplish same effect without using $value
? like
my $result = qx (some-shell-command . ' '. get_value());
i know why sec approach doesn't work, it's demonstrate idea.
my $result = qx(some-shell-command @{[ get_value() ]}); # or dereferencing single scalar value # (last 1 get_value if returns more one) $result = qx(some-shell-command ${ \get_value() });
but rather utilize first option.
explanation: perl arrays interpolate within ""
, qx()
, etc.
above array reference []
holding result of function, beingness dereferenced @{}
, , interpolated within qx()
.
perl qx
No comments:
Post a Comment