Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re: DBI Style Inquiry

by Eily (Vicar)
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; }

Replies are listed 'Best First'.
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 browsing the Monastery: (11)
As of 2016-10-25 14:07 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (320 votes). Check out past polls.