is it possible or how to send the return value of a subroutine A asan inputarguments to subroutine B ?
Sure, by placing a subroutine call inside the parens which delimit another sub-call's arguments. If
sub A { return $_[0] x 2 . ' (from A)'; } sub B { my $arg = shift; return "B got $arg as argument\n"; }
then
print B(A("c")),"\n";
results in
B got cc (from A) as argument
The return value from A() ends up at the right place - inside the parens of B().
--shmem
_($_=" "x(1<<5)."?\n".q·/)Oo. G°\ /
/\_¯/(q /
---------------------------- \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
In reply to Re: Subroutine's output as input to a subroutine
by shmem
in thread Subroutine's output as input to a subroutine
by props
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |