http://qs321.pair.com?node_id=31338

rodry has asked for the wisdom of the Perl Monks concerning the following question:

Here is the code in question

my $tabla = param("tabla"); if ($tabla eq "Miembros") { my $llave = MensajeMiembros(); } sub MensajeMiembros { my $email = param("email"); my $mensaje = "Blah Blah"; return ($email);

When I remove the my from $email it works as expected.

Replies are listed 'Best First'.
Re: Sub with My variable
by cianoz (Friar) on Sep 07, 2000 at 15:11 UTC
    if you write:
    if ($tabla eq "Miembros") { my $llave = MensajeMiembros(); }
    remember $llave is not visible outside the if() block; you should declare it before if you whant to use it outside:
    my $llave; if ($tabla eq "Miembros") { $llave = MensajeMiembros(); }
RE: Sub with My variable
by BlueLines (Hermit) on Sep 07, 2000 at 02:56 UTC


    is it possible that param is returning a list value rather than a scalar? If so,

    my $email = param("email");

    would fail, and you'd want to use

    my ($email) = param("email");

    Extra Disclaimer
    : this is my first post since returning from burningman. My brain may still be jello...

    BlueLines

    Disclaimer: This post may contain inaccurate information, be habit forming, cause atomic warfare between peaceful countries, speed up male pattern baldness, interfere with your cable reception, exile you from certain third world countries, ruin your marriage, and generally spoil your day. No batteries included, no strings attached, your mileage may vary.
RE: Sub with My variable
by Adam (Vicar) on Sep 07, 2000 at 03:10 UTC
    What is the error message?