On 08/04/2013 03:16 PM, Peter Gordon wrote:
On Sun, 4 Aug 2013 07:10:59 +0100, timothy adigun wrote:
my @fruits = qw( apple pear banana ) ;
print join '', map "[$_]", @fruits ;

now you can see each element surrounded by [] and then joined into
one string for printing.

you don't even need the join if you are just printing it but i put
it there so you can use the same concept if you are going to
save the string.

my $str = join  (map "[$_]", @fruits);

you aren't giving join a string arg. it is taking the result of the map in scalar context as the string arg and joining an empty list which gives you an empty string. note the '' in the join line i posted.

uri



--
Uri Guttman - The Perl Hunter
The Best Perl Jobs, The Best Perl Hackers
http://PerlHunter.com

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to