in reply to What Is Going On Here ?????

Hi,

Variable $_ is a global variable and loops like while does not preserve original value of $_. If you use foreach loop inside while loop, that will be fine, since foreach loop preserves original value of $_, whenever loop ends, but while doesn't. So, you should use another variable, for simplicity, and continue ...

#! /usr/bin/perl -w my @test_array=( 'Element2', 'Element3', 'Element4', 'Element5', ); my $item; foreach $item (@test_array) { print "\"$item\"\n"; &do_something(); } print "\n"; foreach $item (@test_array) { print "\"$item\"\n"; } sub do_something { open(IN, "$0") || die("No file"); while (<IN>) { # Do nothing, in the real software we would do something # with the content. } close(IN); }