Colin Johnstone wrote:
>
> Gidday all,
Hello,
> In PHP if I want to add something to a string I do this
>
> $output = "";
>
> $output .= "A";
> $output .= "B";
> $output .= "C";
> $output .= "D";
>
> print $output;
>
> How do I do the same in PERL please.
That does the same thing in perl:
$ perl -le'
$output = "";
$output .= "A";
$output .= "B";
$output .= "C";
$output .= "D";
print $output;
'
ABCD
Of course Perl's motto is "There's more than one way to do it" so:
$ perl -le'
$output = "";
substr $output, length $output, 0, "A";
substr( $output, length $output, 0 ) = "B";
$output =~ s/$/C/;
$output = "${output}D";
vec( $output, length $output, 8 ) = ord "E";
$output = sprintf "%s%s", $output, "F";
print $output;
'
ABCDEF
:-)
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]