$ perl -MO=Deparse -e '$dbh->do("alter session set current_schema = the current schema”);'
Can't find string terminator '"' anywhere before EOF at -e line 1.
$ perl -MO=Deparse -e 'print “third script executed”;'
Unrecognized character \xE2; marked by <-- HERE after print <-- HERE near column 7 at -e line 1.
####
#!/usr/bin/env perl
use strict;
use warnings;
use SpaceCowboy::Database::Module;
my $database_credentials = { ... };
my $sdm = SpaceCowboy::Database::Module::->new($database_credentials);
$sdm->$_() for qw{primary first second third};
##
##
package SpaceCowboy::Database::Module;
use 5.010;
use strict;
use warnings;
use DBI;
sub new {
my ($class, $params) = @_;
return bless $params => $class;
}
{
my $DBH;
sub dbh {
my ($self) = @_;
$DBH //= $self->_connect();
}
}
sub _connect {
my ($self) = @_;
# Use credentials in DBI->connect(...);
# e.g. $self->host(), $self->username(), etc.
return DBI->connect(...);
}
sub primary {
my ($self) = @_;
$self->dbh()->do("alter session ...");
return;
}
sub first {
my ($self) = @_;
$self->dbh()->do("create ...");
$self->dbh()->do("insert ...");
return;
}
# ditto for second() and third()
1;
##
##
$self->dbh()->do($_) for @statements;