my $FH; unless( open( $FH, '<', $sqlFile ) ) { die "Error: can't open file '$sqlFile': $!\n"; } else { local $/ = ';'; while( my $statement = <$FH> ) { chomp( $statement ); my $sth = $dbh->prepare( $statement ) or die "Error in prepare: " . $dbh->errstr; $sth->execute() or die "Error in excute: " . $dbh->errstr; } # while $statement close( $FH ) or die "Error at closing file '$sqlFile': $!\n"; }