#! /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 () { # Do nothing, in the real software we would do something # with the content. } close(IN); }