how many ways string concatenation in perl?
Method 1:
$v='a';
print "$v$v$v";
Method 2:
print "a"."string"."c";
Method 3:
$v='a';
print "a".$v."c";
Method 4:
$v='a';
print "$v".$v.$v;
Method 5:
$v='a';
print join "", "/home/$v.txt";
Method 6:
$v='a';
print join "", "/home/".a.".txt";
Method 7:
$v='a';
print join "", "/home/$v.txt";
Method 8:
$v='a';
print join "", "/home/${v}.txt";
Method 9:
print join('', 'AA',$var1, 'BB', $var2, 'CC');
Method 10:
print sprintf("%sAA%sBB%sCC%s", $var1, $var2);
Method 11:
$s .= $_ for ($v,$v,$v);
print $s;
Method 12:
@vars = ($v,$v,$v);
print join "",@vars;
Method 13:
push @str, $v, $v, $v;
print join '', @str;
Method 14:
@var = ($v,$v,$v);
$s = "@var";
print $s;
Method 15:
undef $";
print "@{[$v,$v,$v]}";
Method 16:
$v='a';
print join(' AA ',sprintf("%s%s", $v, $v),sprintf("%s%s", $v, $v),sprintf("%s%s", $v, $v));
For More Methods Reach Me:@ letscrackperlinterviewblogspot@gmail.com
$v='a';
print "$v$v$v";
Method 2:
print "a"."string"."c";
Method 3:
$v='a';
print "a".$v."c";
Method 4:
$v='a';
print "$v".$v.$v;
Method 5:
$v='a';
print join "", "/home/$v.txt";
Method 6:
$v='a';
print join "", "/home/".a.".txt";
Method 7:
$v='a';
print join "", "/home/$v.txt";
Method 8:
$v='a';
print join "", "/home/${v}.txt";
Method 9:
print join('', 'AA',$var1, 'BB', $var2, 'CC');
Method 10:
print sprintf("%sAA%sBB%sCC%s", $var1, $var2);
Method 11:
$s .= $_ for ($v,$v,$v);
print $s;
Method 12:
@vars = ($v,$v,$v);
print join "",@vars;
Method 13:
push @str, $v, $v, $v;
print join '', @str;
Method 14:
@var = ($v,$v,$v);
$s = "@var";
print $s;
Method 15:
undef $";
print "@{[$v,$v,$v]}";
Method 16:
$v='a';
print join(' AA ',sprintf("%s%s", $v, $v),sprintf("%s%s", $v, $v),sprintf("%s%s", $v, $v));
For More Methods Reach Me:@ letscrackperlinterviewblogspot@gmail.com
0 Comments:
Post a Comment
Note: only a member of this blog may post a comment.
<< Home