vishnu.kuma...@wipro.com wrote:
Hi,
Hello,
I am trying to convert the string abc.def.ghi.amm to abcdefghiamm using split and concatenation. I am missing something somewhere. . please help me to fix the code my $string = "abc.def.ghi.amm"; my @d = split(/\./,"$string"); my $e = @d; for (my $i=0; $i< $e; $i++) { print("Value of array element $i is $d[$i]\n"); } #concatenation for (my $i=0; $i< $e; $i++) { my $abc .= "$d[$i]";
my() creates the $abc variable inside the loop so it is only visible inside the loop.
} print("Value after concatenation is $abc\n"); Output I am getting is Value after concatenation is "amm"
That is not possible because the variable $abc is not visible at file scope. John -- Any intelligent fool can make things bigger and more complex... It takes a touch of genius - and a lot of courage to move in the opposite direction. -- Albert Einstein -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/