RE: Joining array elements
BTW, what George is showing there is an Array Slice. That's why the @ symbol is used instead of the $ symbol. I'd recommend looking it up in the perldocs. -Original Message- From: George Schlossnagle [mailto:[EMAIL PROTECTED]] Sent: Tuesday, October 08, 2002 9:26 AM To: Frank Wiles Cc: Diego Riano; [EMAIL PROTECTED] Subject: Re: Joining array elements join ",", @array[2...$#array]; works nicely for me. Frank Wiles wrote: > .--[ Diego Riano wrote (2002/10/08 at 16:50:41) ]-- > | > | Hello all > | > | I have an array like this: > | > | @array=(1,2,3,4,5,6); > | > | And I would like to join the element starting from the third one until > | the lasta want. Something like: > | > | join (",",$array[2],$array[3],$array[4],$array[5]); > | > | The problem I have is that this array will chance from time to time > | sometimes being bigger sometimes being smaller, so I need a way to join > | the elements from the third element to last one.. > | any Ideas!! > | > `- > >Easiest way would be something along the lines of: > ># Build a temporary array >my @tmp_array = @array; > ># remove the first two elements >shift(@tmp_array); >shift(@tmp_array); > >join(",", @tmp_array); > >Hope this helps. > > - > Frank Wiles <[EMAIL PROTECTED]> > http://frank.wiles.org > - > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Joining array elements
join ",", @array[2...$#array]; works nicely for me. Frank Wiles wrote: > .--[ Diego Riano wrote (2002/10/08 at 16:50:41) ]-- > | > | Hello all > | > | I have an array like this: > | > | @array=(1,2,3,4,5,6); > | > | And I would like to join the element starting from the third one until > | the lasta want. Something like: > | > | join (",",$array[2],$array[3],$array[4],$array[5]); > | > | The problem I have is that this array will chance from time to time > | sometimes being bigger sometimes being smaller, so I need a way to join > | the elements from the third element to last one.. > | any Ideas!! > | > `- > >Easiest way would be something along the lines of: > ># Build a temporary array >my @tmp_array = @array; > ># remove the first two elements >shift(@tmp_array); >shift(@tmp_array); > >join(",", @tmp_array); > >Hope this helps. > > - > Frank Wiles <[EMAIL PROTECTED]> > http://frank.wiles.org > - > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Joining array elements
.--[ Diego Riano wrote (2002/10/08 at 16:50:41) ]-- | | Hello all | | I have an array like this: | | @array=(1,2,3,4,5,6); | | And I would like to join the element starting from the third one until | the lasta want. Something like: | | join (",",$array[2],$array[3],$array[4],$array[5]); | | The problem I have is that this array will chance from time to time | sometimes being bigger sometimes being smaller, so I need a way to join | the elements from the third element to last one.. | any Ideas!! | `- Easiest way would be something along the lines of: # Build a temporary array my @tmp_array = @array; # remove the first two elements shift(@tmp_array); shift(@tmp_array); join(",", @tmp_array); Hope this helps. - Frank Wiles <[EMAIL PROTECTED]> http://frank.wiles.org - -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Joining array elements
read up on slices; join (",", @array[2 .. $#array]); > -Original Message- > From: Diego Riano [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, October 08, 2002 10:51 AM > To: [EMAIL PROTECTED] > Subject: Joining array elements > > > Hello all > > I have an array like this: > > @array=(1,2,3,4,5,6); > > And I would like to join the element starting from the third one until > the lasta want. Something like: > > join (",",$array[2],$array[3],$array[4],$array[5]); > > The problem I have is that this array will chance from time to time > sometimes being bigger sometimes being smaller, so I need a > way to join > the elements from the third element to last one.. > any Ideas!! > > Thanks > > Diego Riano > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Joining array elements
Diego Riano wrote: > I have an array like this: > > @array=(1,2,3,4,5,6); > > And I would like to join the element starting from the third one until > the lasta want. Something like: > > join (",",$array[2],$array[3],$array[4],$array[5]); > > The problem I have is that this array will chance from time to time > sometimes being bigger sometimes being smaller, so I need a way to join > the elements from the third element to last one.. > any Ideas!! join ",", @array[2..$#]; Greetings, Janek -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]