find_cycle($obj);
####
--------------------------------
package Obj;
sub new
{
my $class = shift;
my $name = shift;
my $value = shift;
my $self = {
NAME => $obj,
VALUE => $value
};
bless $self, $class;
return $self;
}
return 1;
--------------------------------
# main.pl
--------------------------------
my @objects = ();
my $i = 0;
while($i < 20000000) {
@objects = getObjects();
# do something
$i += 100;
}
sub getObjects
{
my @objects = ();
my $object = undef;
my %ht = (); # say i use a hash somewhere in here
my $i = 0;
for($i=0; $i<100; $i++) {
$object = new Obj("name_$i", $i);
$objects[$i] = $object
}
return @objects;
}
####
use Win32::ODBC;
my @objects = ();
my $i = 0;
while($i < 20000000) {
@objects = getObjects();
# do something
$i += 100;
}
sub getObjects {
my @objects = ();
my $object = undef;
my $db = undef;
my $i = 0;
$db = new Win32::ODBC("DSN=dsnname;UID=username;PWD=pw%") || die;
for($i=0; $i<100; $i++) {
#$object = new Obj("name_$i", $i);
$objects[$i] = $object
}
if($db) {
$db->Close();
}
return @objects;
}