Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Let's say "string1" is $array[2] now I want to be able to create a @new with $array[2] and $array[3] concatentated. I'm guessing I'd use join somehow (ie, my @new = join($array[$i], $array[$i+1];), but am having problems figuring out how to do $array[$?] + 1 element when I don't know statically what the matching array element number is.#!/usr/bin/perl my $file = '/output.txt'; open DATA, "$file" or die "can't open file"; my @array = <DATA>; for($i=1; $i < 10; $i++) { foreach my $found ($array[$i]) { if ( $found =~ /string1/ ) { my @new = join($array[$i], $array[$i++]); } } } close (DATA);
Anybody have any idea's?
Thanks,
Jim
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: array element question
by jdporter (Paladin) on Nov 21, 2006 at 23:16 UTC | |
|
Re: array element question
by chromatic (Archbishop) on Nov 22, 2006 at 02:13 UTC | |
by robot_tourist (Hermit) on Nov 22, 2006 at 14:26 UTC | |
|
Re: array element question ($prev)
by tye (Sage) on Nov 21, 2006 at 23:53 UTC | |
by Anonymous Monk on Nov 22, 2006 at 00:45 UTC | |
|
Re: array element question
by GrandFather (Saint) on Nov 21, 2006 at 23:24 UTC |