-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
I get the idea that you're trying to get a list of lines with the
@ReturnAry = split "\n", qqx ( curl $TimeOutStr -L $Url -o
$FileName; echo \$\? );
You can use the lines[1] sub for exactly this. Similarly for this line
for @ReturnAry[ 0 .. @ReturnAry.elems - 3 ] -> $Line
You can use the head[2] sub to write it as
for @ReturnAry.head(*.elems - 3) -> $line
Also, on the
$ReturnStr += $Line
If you're trying to concatenate a string, you should use the ~ instead
of the +, so it'd become
$ReturnStr ~= $Line
[1]: https://docs.perl6.org/routine/lines
[2]: https://docs.perl6.org/routine/head
On Sat, 28 Jul 2018 23:46:30 -0700
ToddAndMargo <[email protected]> wrote:
> On 07/28/2018 01:37 AM, ToddAndMargo wrote:
> > Hi All,
> >
> > How do I get the bash return code ("$?") from
> > the following?
> >
> > $ReturnStr = qqx ( curl $TimeOutStr -L $Url -o $FileName ).lines;
> >
> >
> > Many thanks,
> > -T
>
>
> Followup:
>
> This is what I came up with:
>
> if $ProgressBar {
> # This need a space ofter the qqx
> # $ p6 'my $x="cat /etc/hosts; echo \$\?"; my @y = split "\n",
> qqx ( $x ); say @y[@y.elems-2];'
> # 0
> # <blank line>
>
>
> @ReturnAry = split "\n", qqx ( curl $TimeOutStr -L $Url -o
> $FileName; echo \$\? );
> for @ReturnAry[ 0 .. @ReturnAry.elems - 3 ] -> $Line {
> $ReturnStr += $Line; }
> print "\n";
> $ReturnCode = @ReturnAry[ @ReturnAry.elems - 2 ];
>
> } else {
> ( $ReturnStr, $ReturnCode ) = RunNoShell ( "curl $TimeOutStr
> -L $Url -o $FileName" );
> }
> return ( $ReturnStr, $ReturnCode );
-----BEGIN PGP SIGNATURE-----
iQEzBAEBCAAdFiEE4eL662U9iK2ST2MqN/W6H45XOE8FAltdkOYACgkQN/W6H45X
OE+73gf+Ko8Wrm3aySxtsMsuVAWT+V4iNanSpEo8jj27+OUgQCmC1vY0yR7BkrJS
vb1WnM2TvzrxBlc/L9QF7dJaJfBkcB2Nera+PJWkdZlYegvmA9vKHbjyxl/Nvyi6
8M1GjtsmTKUFz3OT3T60fXYiRwiu2vG+OBeN4riWDI4HO9OiXw+kqcuUsymavNo3
6YdXXhwyfKLx+kdsIT1UAfSfWY+B53attz/XwTkiz8VH3cSP1zQtvx+zh5KbvA+i
CViRZQAvkeasQ77d70H9fd+oYhgJqHCF5/SSlB1MDP2Rn9YZDxhfDgsHuNEWjplm
7NTZDIMBn5JXLgSOkyulC+xIBG0sXg==
=Dk+C
-----END PGP SIGNATURE-----