Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Or Operator

by rjahrman (Scribe)
on Jul 30, 2004 at 22:53 UTC ( #378826=note: print w/replies, xml ) Need Help??


in reply to Or Operator

(It's me again.)

BTW, I got it to work with:
$page = $cgi->param("page") or $page = "login";

But this:
my $page = $cgi->param("page") or $page = "login";
Fails. Why? Is there something I can change to make it work?

Replies are listed 'Best First'.
Re^2: Or Operator
by ysth (Canon) on Jul 31, 2004 at 01:32 UTC
    my $page = $cgi->param("page") or $page = "login";
    fails because that second $page is really the global variable; the scope where "$page" refers to the my variable only starts on the following statement. use strict would have alerted you to this (unless you have an outer $page, which is not a good idea for keeping your code maintainable.)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://378826]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (9)
As of 2016-09-26 21:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Extraterrestrials haven't visited the Earth yet because:







    Results (491 votes). Check out past polls.