manoj_speed has asked for the wisdom of the Perl Monks concerning the following question:
Hi All,
I would like to concatenate more than one variable in assignment.
For Ex:
If I want to assign two variables in a single shot. I can use this.
($myvar1, $myvar2) = ('testing1', 'testing2');
Likewise, I would like to use this for two variables concatenation in a single shot.
($myvar1, $myvar2) = ('Hi ', 'Hello');
($myvar1, $myvar2) .= ('Welcome', 'World');
print "$myvar1, $myvar2\n"; # prints Hi, HelloWorld
The above code is doing appending value for variable-2 only.
Is there any possible way to do this in a single statement ?
I would like to concatenate more than one variable in assignment.
For Ex:
If I want to assign two variables in a single shot. I can use this.
($myvar1, $myvar2) = ('testing1', 'testing2');
Likewise, I would like to use this for two variables concatenation in a single shot.
($myvar1, $myvar2) = ('Hi ', 'Hello');
($myvar1, $myvar2) .= ('Welcome', 'World');
print "$myvar1, $myvar2\n"; # prints Hi, HelloWorld
The above code is doing appending value for variable-2 only.
Is there any possible way to do this in a single statement ?
--
The wisest mind has something yet to learn.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Concatenating more than one variable in perl
by LanX (Saint) on Jun 19, 2014 at 14:18 UTC | |
by AnomalousMonk (Archbishop) on Jun 19, 2014 at 16:15 UTC | |
by LanX (Saint) on Jun 19, 2014 at 22:41 UTC | |
Re: Concatenating more than one variable in perl
by Athanasius (Archbishop) on Jun 19, 2014 at 14:08 UTC | |
Re: Concatenating more than one variable in perl
by toolic (Bishop) on Jun 19, 2014 at 13:50 UTC | |
by perlfan (Vicar) on Jun 19, 2014 at 15:49 UTC | |
Re: Concatenating more than one variable in perl
by MidLifeXis (Monsignor) on Jun 19, 2014 at 17:14 UTC | |
Re: Concatenating more than one variable in perl
by perlfan (Vicar) on Jun 19, 2014 at 15:48 UTC |
Back to
Seekers of Perl Wisdom