Hi Peter,

On Sun, 4 Aug 2013 19:16:32 GMT
Peter Gordon <pete...@netspace.net.au> 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);
> say $str;
> 
> This code outputs a blank line & I can't see how to produce
> a string of the required output using join & map.  Anybody
> have an answer?

Are you using strict and warnings? Did you define the contents of @fruits (and
hopefully declare it)? If @fruits is empty, then $str will be zero-length.

Regards,

        Shlomi Fish

> Thanks
> 



-- 
-----------------------------------------------------------------
Shlomi Fish       http://www.shlomifish.org/
List of Text Editors and IDEs - http://shlom.in/IDEs

Chuck Norris does not own a dishwasher. His dishes know better than to become
dirty.
    — http://www.shlomifish.org/humour/bits/facts/Chuck-Norris/

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
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