![]() |
DRaw a blank on combinging two arrays
Earlier I was trying to combing 2 arrays and totally drew a blank on
how to do it. I though it would be join but didn't seem to work. Can someone tell me what to look up in perldoc for it? I thought I could used something like @c = join(@a,@b); but just ended up with one long string. Bill H |
Re: DRaw a blank on combinging two arrays
Bill H <bill@ts1000.us> wrote:
> Earlier I was trying to combing 2 arrays and totally drew a blank on > how to do it. I though it would be join but didn't seem to work. Can > someone tell me what to look up in perldoc for it? > I thought I could used something like @c = join(@a,@b); but just ended > up with one long string. It's not clear what you mean exactly with "combine to arrays", but your attempt with join makes it look as you simply want to append the elements of @b to that of @a and have the result in a third array. And in that case the you're looking for too complicated a solution, a simple @c = ( @a, @b ); is all you need. If you instead want to append the elements from @b to @a you would do push @a, @b; Regards, Jens -- \ Jens Thoms Toerring ___ jt@toerring.de \__________________________ http://toerring.de |
Re: DRaw a blank on combinging two arrays
Bill H wrote:
>Earlier I was trying to combing 2 arrays and totally drew a blank on >how to do it. I though it would be join but didn't seem to work. Can >someone tell me what to look up in perldoc for it? > >I thought I could used something like @c = join(@a,@b); but just ended >up with one long string. Simple enough: @c = (@a, @b); or @c = @a; # copy @a push @c, @b; # add @b -- Bart. |
Re: DRaw a blank on combinging two arrays
On Jun 18, 4:29*pm, j...@toerring.de (Jens Thoms Toerring) wrote:
> Bill H <b...@ts1000.us> wrote: > > Earlier I was trying to combing 2 arrays and totally drew a blank on > > how to do it. I though it would be join but didn't seem to work. Can > > someone tell me what to look up in perldoc for it? > > I thought I could used something like @c = join(@a,@b); but just ended > > up with one long string. > > It's not clear what you mean exactly with "combine to arrays", but > your attempt with join makes it look as you simply want to append > the elements of @b to that of @a and have the result in a third > array. And in that case the you're looking for too complicated a > solution, a simple > > * @c = ( @a, @b ); > > is all you need. If you instead want to append the elements from > @b to @a you would do > > * push @a, @b; > * * * * * * * * * * * * * *Regards, Jens > -- > * \ * Jens Thoms Toerring *___ * * *j...@toerring.de > * *\__________________________ * * *http://toerring.de Thanks Jens - yeah thats what I wanted to do and I just could not figure it out - new it was simple but I was looking for something complex instead of thinking simple! Bill H |
| All times are GMT. The time now is 12:32 PM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.