Executing stored procedure using Perl

Jonathan Rockway jon at jrock.us
Wed Mar 19 17:22:17 GMT 2008


* On Wed, Mar 19 2008, David Cantrell wrote:
> On Wed, Mar 19, 2008 at 03:19:32PM +0000, James Laver wrote:
>
>> Except since I used placeholders you'd want to pass something into execute
>> $stmt->execute($a,$b);
>
> Of course, $a and $b are usually a bad idea ...
>
> They're Special in sort blocks and using them elsewhere would be
> confusing.

What's more confusing is that there are people that think that using a
variable like $a or $foo in an example means they should use that exact
name in their application.

Finally, there are legitimate uses for $a and $b, like:

  sub roots_of_quadratic {
      my ($a, $b, $c) = @_;
      $d = ...;
      return ( (-$b+$d)/2, (-$b-$d)/2 );
  }

This will work even if you do:

  sort { roots_of_quadaratic ...; $a <=> $b } ...

because the static $a and $b don't affect the dynamic $main::a and
$main::b (or whatever package they're in).

Regards,
Jonathan Rockway

-- 
print just => another => perl => hacker => if $,=$"


More information about the london.pm mailing list