Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

what is the usage of Test::More doing for me that 'defined ($dbh)' is not doing?
$dbh = DBI->connect( $connect_string, \%attr ); isa_ok $dbh, 'DBI::db'; if ( defined($dbh) ) { write_log( "INFO ", "Database connection OK" ); } else { write_log( "FAIL ", "Fail: $connect_string" ); write_log( "FAIL ", "Error connecting to database: Error $D +BI::err - $DBI::errstr" ); die "Error connecting to database: Error $DBI::err - $DBI::err +str"; }

Replies are listed 'Best First'.
Re: Test::More usage
by tobyink (Canon) on Sep 11, 2013 at 17:46 UTC

    I could be wrong, but you appear to be using Test::More in application code. Don't do that.

    Test::More is a framework for writing test suites.

    use Moops; class Cow :rw { has name => (default => 'Ermintrude') }; say Cow->new->name
      thanks for your answer...if you could see that I am blushing for such a silly question.