Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Sub with My variable

by rodry (Beadle)
on Sep 07, 2000 at 02:44 UTC ( [id://31338]=perlquestion: print w/replies, xml ) Need Help??

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?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://31338]
Approved by erzuuli
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (6)
As of 2024-04-25 12:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found