tphyahoo has asked for the wisdom of the Perl Monks concerning the following question:
It has an eval in it, because I want to "do two semicolon-separated things" on the left side of an if/unless. What I mean is, if this bit in curly brackets was on the right side of the if/unless, I wouldn't need the eval statement, it would just flow from the syntax.$ perl -e 'my $type="blee"; eval { print "bad type\n"; print "blee\n" +} unless ($type eq "newer" || $type eq "older")' bad type blee
I never ever use eval, here I just kind of popped it out to see what would happen.
So I guess what I'm asking is, other than having that extra "eval" statement, is there something else wrong with what I am doing here?
Should I fear eval?
And should I fear trying to do more than one "semicolon-separated thing" on the left side of an if/unless statement?
UPDATE:
1) Changed single quotes to double quotes.
2) Obviously, I wanted "do" here. Thanks for helping -- I think I got three answers to my question in under 45 seconds, and not a single RTFM. wow :)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Should I fear eval? (want to do two things on the left side of an if/unless)
by Corion (Patriarch) on Aug 10, 2006 at 12:17 UTC | |
|
Re: Should I fear eval? (want to do two things on the left side of an if/unless)
by davorg (Chancellor) on Aug 10, 2006 at 12:20 UTC | |
|
Re: Should I fear eval? (want to do two things on the left side of an if/unless)
by jhourcle (Prior) on Aug 10, 2006 at 12:20 UTC | |
|
Re: Should I fear eval? (want to do two things on the left side of an if/unless)
by ikegami (Patriarch) on Aug 10, 2006 at 15:09 UTC | |
by Anonymous Monk on Aug 11, 2006 at 08:30 UTC | |
|
Re: Should I fear eval? (want to do two things on the left side of an if/unless)
by broquaint (Abbot) on Aug 11, 2006 at 11:20 UTC |