Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re: DBI Style Inquiry

by Eily (Deacon)
on Jun 27, 2013 at 08:51 UTC ( #1040961=note: print w/ replies, xml ) Need Help??

in reply to DBI Style Inquiry

You could "name" your first parameter by assigning its value to a lexical. Like chomp(my $param = $_[0]);. But that's not really much change, and that's up to you.

However, there is a problem with your code. The "return" statement exits the sub immediatly, and everything below that point is skipped. Besides, you assign the result of fetchrow_array() to an array that you never use (you could have written return $sth->fetchrow_array();). If you want the end of the sub to be run, you should have something like:

sub get_loc { ... my @loc = $sth->fetchrow_array(); $sth->finish; $dbh->disconnect or die "Error disconnecting: $DBI::errstr\n"; return @loc; }

Comment on Re: DBI Style Inquiry
Select or Download Code
Re^2: DBI Style Inquiry
by edict (Novice) on Jun 27, 2013 at 09:10 UTC
    Concerning the return statement, apparently it is commonly known that the subroutines exit there but I was ignorant about that fact (I've never taken a programming class, to be honest). Thank you for your input!

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1040961]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2015-01-30 05:58 GMT
Find Nodes?
    Voting Booth?

    My top resolution in 2015 is:

    Results (248 votes), past polls