#!/usr/bin/env perl use strict; use warnings; use DBI; use Carp; use English; my $dbh = DBI->connect('dburl', 'dbuser', 'dbpassword', {AutoCommit => 0, RaiseError => 0}) or croak($EVAL_ERROR); foreach my $fname (qw[pdi pitchover contactlight engineshutdown]) { print "Executing file $fname\n"; open($my $ifh, '<', $fname) or croak($ERRNO); while((my $line = <$ifh>)) { chomp $line; # Remove linebreak character # Ignore empty lines and comments next if($line eq '' || $line =~ /^\#/); if(!$dbh->do($line)) { # It's a 1202 program alarm, abort the landing $dbh->rollback; croak($dbh->errstr); } } close $ifh; } # Tranquility base here, the Eagle has landed $dbh->commit;