in reply to passing variables to a sub

What you get is not an error, but a warning.

To get rid of it you could either properly initialize the offending variable or turn the warnings off (get rid of "use warnings" or use a lexical "no warnings").

Apart from that you should not use lexicals in a global way.

When you do

sub ownertbl { ( $sortby, $ascdesc, $letter ) = @_;
You are referencing (and possibly changing!) variables that are defined somewhere else.

Instead do it like this:

sub ownertbl { my ( $sortby, $ascdesc, $letter ) = @_;
Now (notice the "my"!) you have variables that are local to the sub.

Replies are listed 'Best First'.
Re^2: passing variables to a sub
by ag4ve (Monk) on Oct 16, 2010 at 04:18 UTC
    if i do:
    sub ownertbl { my ( $sortby......

    i get an error saying that the variable was already defined in the same scope (something to that effect).

    also, the warning isn't really the point. it is there telling me i'm screwing up. however, the point is that these values becoming undefined in my sub is causing my sql statement to fail and my page to pretty much fail in its own right.