Yenya's World

Tue, 14 Mar 2006

A Perl bug?

I have seen a strange behaviour of Perl code - the minimal code which triggers this is along the following lines:


use DBIx::ShowCaller;
# use DBI;
my $dbh = DBIx::ShowCaller->connect('dbi:Oracle:', 'dbuser', 'dbpass')
# my $dbh = DBI->connect('dbi:Oracle:', 'dbuser', 'dbpass')
        or die;

my $temp_file = "/tmp/input.txt";

open(TEMP, $temp_file) or die "Can't open $temp_file: $!\n";
my $text = join('',<TEMP>);
close TEMP;

for my $radek (split (/\n/, $text)) {
        my $rv;
        ($rv) = $dbh->selectrow_array('SELECT 1 FROM DUAL');
#       ($rv) = $dbh->selectrow_array('SELECT 1 FROM DUAL');
        if ($rv) { print "is ok\n"; } else { print "NOT OK!\n"; }

Do not even try to find out why TF it is written this way - it has been created by pruning and testing the larger script. It returns "NOT OK" from the SELECT. However, any of the following changes makes it work:

Strange, ins't it? I have tested on both Linux/i386 and Linux/ia64 (with different versions of the Oracle client, altough DBI and DBD::Oracle have the same version number on both systems). Also selectrow_arrayref() has the same behavour. It is Perl 5.8.6. What's going on there?

Section: /computers (RSS feed) | Permanent link | 0 writebacks


Yenya's World: Linux and beyond - Yenya's blog.


RSS feed

Jan "Yenya" Kasprzak

The main page of this blog



Blog roll:

alphabetically :-)