I have been told that I'm sorta OCD when it comes to my programming style, and being relatively new to Perl, I am seeking wisdom.
My code needs to be easily readable and uniformly.. um.. formatted, and concise. So let me get to the point.
Here's some code to grab info from a database (I only need one field). It looks terrible to me, but it works; and I am asking advice on how to make it less fugly.
sub get_loc { chomp $_[0]; my $dbh = DBI->connect("DBI:mysql:tracker:12.34.56.78", 'myuser', +'mypassword' ) or die "Connect to database failed: $DBI::errstr\n"; my $sth = $dbh->prepare("SELECT location FROM servers WHERE name=? + LIMIT 1") or die "Couldn't prepare statement: $DBI::errstr\n"; $sth->execute($_[0]); return my @loc = $sth->fetchrow_array(); $sth->finish; $dbh->disconnect or die "Error disconnecting: $DBI::errstr\n"; }
Thank you!
In reply to DBI Style Inquiry by edict
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |