in reply to Aggregating text and variables into a new variable
my $gser2= join ';', $gser[0],$gser[1],$gser[2],$gser[3],$gser[4];
Can be shortened to this:
my $gser2 = join ';', @gser[0..4];
or even this:
my $gser2 = join ';', @gser;
Update: Another way is to use the special variable $" to stringify an array:
use strict; use warnings; { local $" = q{;}; # locally redefine list separator my @gser = 1..5; my $gser2 = "@gser"; # the double quotes force interoplation print "gser2 = $gser2\n"; } __END__ gser2 = 1;2;3;4;5
|
|---|