<?xml version="1.0" encoding="windows-1252"?>
<node id="968941" title="Re: foreach only for a section of a list" created="2012-05-04 11:20:58" updated="2012-05-04 11:20:58">
<type id="11">
note</type>
<author id="922586">
Lotus1</author>
<data>
<field name="doctext">
&lt;p&gt;Here are two other ideas: you can store and print the previous value each iteration or you can pop the final element off the array then use foreach on the remaining elements.&lt;/p&gt;
&lt;c&gt;
use strict;
use warnings;

my @somewords = qw(a b c d);

my $previous_core = '';

foreach my $core (@somewords) {
  print "$previous_core\n" if $previous_core ne '';
  $previous_core=$core;
}
print "************\n";

my $popword = pop @somewords;
print "popped &gt;${popword}&lt;\n";

print "\@somewords:\n";
print "$_\n" foreach @somewords;

print "************\n";
&lt;/c&gt;</field>
<field name="root_node">
968933</field>
<field name="parent_node">
968933</field>
</data>
</node>
