roman has asked for the wisdom of the Perl Monks concerning the following question:
Recently I tried to wrap some DBI stuff. I found that when calling selectrow_array via goto, the list context is lost:
Outputuse strict; use DBI; use File::Temp; my $temp = File::Temp->new; my $dbh = DBI->connect('dbi:SQLite:dbname='. $temp->filename, '', ''); $dbh->do("create table sample1 (id number )"); $dbh->do("INSERT INTO sample1 (id) VALUES (1)"); sub selectrow_array { goto &{ $dbh->can('selectrow_array') }; } my $statement = "SELECT 'a', 'b', 'c' FROM sample1"; warn $dbh->selectrow_array($statement); warn selectrow_array($dbh, $statement);
abc a
As you see from the output, second selectrow_array behaves like being called in scalar context and returns the first value only.
Is there any simple explanation for this behaviour?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: List context lost when goto selectrow_array?
by dragonchild (Archbishop) on Mar 20, 2008 at 13:36 UTC | |
by roman (Monk) on Mar 20, 2008 at 21:21 UTC | |
by dragonchild (Archbishop) on Mar 21, 2008 at 15:27 UTC | |
|
Re: List context lost when goto selectrow_array?
by Anonymous Monk on Mar 21, 2008 at 18:49 UTC |