my $dbh = DBI->connect("DBI:Pg:host=192.168.12.23;port=5432;","adhi");
print "Connected successfully\n";
my $exe = $dbh->prepare("delete from perl_test.test");
my $res = $exe->execute();
print "deleted the table successfully of rows: $res\n";
It is done in this way to allow to test whether the operation was successful. The reason is that
'0E0' (as a string) is a true value, but
0 is a false value in Perl. Therefore:
you can test the return value in
if to determine whether the operation was successful (true means success),
but you can also use the return value as a number to know the exact number of deleted rows, since 0E0 evaluates to 0 when used as a number.
If you need just the number of deleted rows, you can use
$res + 0 or
$res * 1. But only after you have tested that the operation was successful.
More about true and false values: True and false