That does work because of the super-low-precedence of 'or'.Actually, it doesn't work. The if wants to evaluate all of the following expression. It's not very readable, thougheither.: someone who doesn't understand the lower-precedence-ness of 'or' (compared to '||', especially). To them it would look like you shouldIt will try to eval $PAGE if one of the two or statements is true. Also, you don't need to specify main-> for nopageerror.
For clarity, I suggest one of these:
# whoops, syntax errors, thanks to Roy Johnson
## ( eval "$PAGE" if main->can($PAGE) ) or nopageerror;
## or...
#( eval "$PAGE" if main->can($PAGE) )
# or nopageerror;
## or...
if ( main->can($PAGE) ) { eval $PAGE }
else { nopageerror }
Updates:
- 2005-09.Sep-30 : fixed stupid errors as pointed out by Roy Johnson. Don't code without coffee, kids! :-)
<-radiant.matrix->
Larry Wall is Yoda: there is no try{} (ok, except in Perl6; way to ruin a joke, Larry! ;P)
The Code that can be seen is not the true Code
"In any sufficiently large group of people, most are idiots" - Kaa's Law
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.