# I assume @systems is already initialized and full of data.
# the important thing is that you do this loop for each
# system.
my @drives;
#loop over the systems
foreach (@systems) {
while ( THERE ARE MORE DRIVES ) {
#get drive info
push @drives, {system=>SYSTEMID,
make=>MAKE,
model=>MODEL,
capacity=>CAPACITY,
status=>STATUS
};
}
####
# prepare once, execute often
my $sth= $db->prepare("INSERT INTO drives (system_id, make, model, capacity, status, last_update) VALUES (?,?,?,?,?,NOW())");
foreach my $drive (@drives) {
$sth->execute($drive->{system}, $drive->{make}, $drive->{model}, $drive->{capacity}, $drive->{status});
}
####
perl -e 'print "How sweet does a rose smell? "; chomp ($n = ); $rose = "smells sweet to degree $n"; *other_name = *rose; print "$other_name\n"'