Greetings,

Thanks Michael for your detailed explanation.

best,

Shaji 
-------------------------------------------------------------------------------
Your talent is God's gift to you. What you do with it is your gift back to God.
-------------------------------------------------------------------------------


________________________________
 From: Michael Rasmussen <mich...@jamhome.us>
To: *Shaji Kalidasan* <shajiin...@yahoo.com> 
Cc: Perl Beginners <beginners@perl.org> 
Sent: Sunday, 4 August 2013 10:37 AM
Subject: Re: using join
 

On Sun, Aug 04, 2013 at 12:59:29PM +0800, *Shaji Kalidasan* wrote:
> Greetings,
> 
> I am facing some difficulty using join to display the array elements
> 
> Here is the code snippet
> 
> [code]
> use strict;
> use warnings;
> 
> my @fruits = qw/apple mango orange banana guava/;
> 
> print '[', join '][', @fruits, ']';
> [/code]
> 
> How can I make the output to eliminate the last empty square brackets [] 
> using a single print statement. I used two print statements as shown in the 
> code snippet above (#lines are commented out)

Limit what join acts on by using parenthesis.
   print '[', join ( '][', @fruits ), ']';

This keeps your closing bracket from being part of the list that join is acting 
upon.

-- 
            Michael Rasmussen, Portland Oregon  
          Be Appropriate && Follow Your Curiosity
  Other Adventures: http://www.jamhome.us/ or http://gplus.to/MichaelRpdx
A special random fortune cookie fortune:
Follow the carrot.
    ~ http://someoneoncetoldme.com/gallery/14052010

Reply via email to