<?xml version="1.0" encoding="windows-1252"?>
<node id="996851" title="Re^2: new to perl, need some help" created="2012-10-02 08:05:04" updated="2012-10-02 08:05:04">
<type id="11">
note</type>
<author id="911740">
bimleshsharma</author>
<data>
<field name="doctext">
&lt;p&gt; Here is issue with initialisation of array(@values = ();).  It is reinitialising on every iteration of loop and ultimately storing last value. Use below hope that will fulfil your requirement&lt;/p&gt;

&lt;code&gt;
!#/usr/bin/perl

use strict;
use warnings;

@number = qw(1 2 3 4 5 10 11 12 13 14);

print "The values within the array are @number\n\n";

print "We will now print the square root of each number in the array a
+s long as it falls between the range of 100-200 \n\n";
my @values = ();
foreach $num (@number)
{
$sq = $num * $num;
if ($sq &gt;= 100 &amp;&amp; $sq &lt;= 200)
{

push(@values, $sq);
}
}
print "Obtaining square values using foreach loop: @values\n";
&lt;/code&gt;</field>
<field name="root_node">
996795</field>
<field name="parent_node">
996796</field>
</data>
</node>
