in reply to Concatenating more than one variable in perl

> Is there any possible way to do this in a single statement ?

most likely a XY Problem, people who number their vars hate arrays.

Though for fun...

DB<110> use List::MoreUtils "pairwise" DB<111> ($x,$y)=("X","Y") => ("X", "Y") DB<112> pairwise { $$a .= $b } @{[\($x,$y)]}, @{["x","y"]} => ("Xx", "Yy") DB<113> $x,$y => ("Xx", "Yy")

Not sure if versions newer than 5.10 allow to get rid of the '@{...}'.

Cheers Rolf

(addicted to the Perl Programming Language)

Replies are listed 'Best First'.
Re^2: Concatenating more than one variable in perl
by AnomalousMonk (Archbishop) on Jun 19, 2014 at 16:15 UTC

    Teach me to number not the vars of my scripts, but the indices of my arrays...

      > Teach me to number not the vars of my scripts, but the indices of my arrays...

      well, if you beg me so nicely... ;-)

      DB<100> use List::MoreUtils "pairwise" DB<101> @vars=qw(X Y) => ("X", "Y") DB<102> @appends=qw(x y) => ("x", "y") DB<103> pairwise { $a .= $b } @vars, @appends => ("Xx", "Yy") DB<104> @vars => ("Xx", "Yy")

      and for completeness

      DB<105> @vars=qw(X Y) => ("X", "Y") DB<106> @vars = pairwise { $a . $b } @vars, @appends => ("Xx", "Yy")

      Cheers Rolf

      (addicted to the Perl Programming Language)