ishootperls has asked for the wisdom of the Perl Monks concerning the following question:
Monks, Here's the situation. I have an array split by periods (.). If the first element contains the word /literal/ join the 1st and 2nd elements together. Allowing the original array to contain the two conjoined elements in the first indice. Here's what I got, but no dice!
UPDATE: I took kennethk's sugestions and Im currently testing out some modifications. Thanks Monks!!foreach my $results (@sorted) { + my @listOfItems = split( /\./, $results); if ( $listOfItems[0] =~ /literal/ ) { $listOfItems[0] = join(".", $listOfItems[0..1]); + } push ( my @array1, $listOfItems[0]); push ( my @array2, $listOfItems[1]); push ( my @array3, $listOfItems[2]); # @array1 should contain the newly conjoined $listOfItems[0] # My bad ! I had some typos in my sample code. It wasnt a # cut and paste from my terminal. So my mistake guys, sorry! # This is what I was actually working with. }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Joining Two Elements of an Array. Little Help Please.
by kennethk (Abbot) on Sep 27, 2012 at 18:20 UTC | |
by ishootperls (Novice) on Sep 27, 2012 at 21:38 UTC | |
|
Re: Joining Two Elements of an Array. Little Help Please.
by toolic (Bishop) on Sep 27, 2012 at 18:07 UTC |