split - Perl - Subroutine argument is another subroutine call -
i have subroutine called greptext, greps text variable. trying split output. possible pass output of greptext argument split directly? without putting value of greptext in variable first ? greptext returns string.
what trying is:
$output = (split ":", greptext("findthis", $alltext))[1];
greptext follows
sub greptext(){ @text = split "\n", $_[1]; $output = grep /$_[0]/, @text; return $output; }
it doesn't work. error
too many arguments main::greptext @ line 115, near "$alltext)"
it very possible pass input of subroutine perl function directly without using perl variable.
i think issue might "greptext" subroutine. debug issue in detail, more information required.
i did try routine , able required output:
#!/usr/bin/perl sub greptext { return "hello:world"; # returns test string } $output = (split ":", greptext($texttofind, $alltext))[1]; print "$output";
output:
world
Comments
Post a Comment