View Full Version : what's wrong with this
what's wrong with the following? when I look in the log files it says there is something wrong with the first } How could I fix it?
Oh yeah, here's part of the program...
if ($oldornew eq "new") {
&new;
}
if ($oldornew eq "old") {
&old;
}
else {
&error;
}
Charles Capps
04-06-1999, 10:02 PM
Perl is VERY picky... Try switching that second if into an elsif, like this:
if ($oldornew eq "new") {
&new;
} elsif ($oldornew eq "old") {
&old;
} else {
&error;
}
------------------
"Okay, so I'm not "SANE" so to speak, but uh... I'm the lovable kind of psycho"
http://solareclipse.net/
I get a syntax error near the first }
Justin
04-06-1999, 10:57 PM
I don't see why you'd get a syntax error - but I do know it should work with just plain if's... Personally I'd throw an exit; statement at the end of each one:
if ($oldornew eq "new") {
&new;
exit;
}
But that's me - just to keep it from running other parts of the script (depends on the rest of the script really).
Other than that, without seeing the rest of the script (or knowing what it is) I don't know what else to say http://www.aota.net/ubb/smile.gif
------------------
Justin Nelson
FutureQuest Support
Can you include some lines that are BEFORE the first if statement?
Rich
I got it to work, ALMOST. Now I am getting a different error which is
Modification of a read-only value attempted
What the script is doing is reading a file and grabbing a line. Does anyone know what that error message means?
Justin
04-07-1999, 01:27 AM
Again, it would be most helpful if we knew what script you are attempting to use (or are you writing it?).
Either way, to write to a file, it must be writable by the script (755 instead of 644).
------------------
Justin Nelson
FutureQuest Support
I'm writing it. The only problem I am having is grabbing one of the lines in a text file and if that line is correct it will go to a subroutine.
jenili
04-09-1999, 09:02 AM
cngo, post your code and we should be able to help you. The lines you've posted don't appear to have any problems, but we can't tell without more context.
The only other thing I can suggest, based on what you've posted, is about that "modification of a read-only value" -- would probably mean you're trying to set the value of a string or something (e.g., you forgot the $ in a variable name). If we had the code to look at, one of us would probably find it.
------------------
jeni
Thanks for the help but with a little more concentration, I figured it out.
vBulletin® v3.6.8, Copyright ©2000-2012, Jelsoft Enterprises Ltd.