Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Comment errors??

Status
Not open for further replies.

jbauer

Technical User
May 30, 2001
2
US
Hello All,
I've run into a problem and am hoping somebody can help me here.

I've got some comments in my script such as:
"line49:#characters: (`'"{}[]()). Something along the lines of a "grep -c" here
line50:#would work well.
line51:#Grep won't work though because it only counts the lines, not the..."

When I run "perl -c script_chkr" I get this:
"String found where operator expected at script_chkr line 51, near "#Grep won'"
(Might be a runaway multi-line '' string starting on line 49) (#1)
String found where operator expected at script_chkr line 51, near "#Grep won'"
(Might be a runaway multi-line '' string starting on line 49)
(Missing semicolon on previous line?)
syntax error at script_chkr line 51, near "#Grep won'"
Bareword found where operator expected at script_chkr line 51, near "#Grep
won't" (#2)

(S) The Perl lexer knows whether to expect a term or an operator. If it
sees what it knows to be a term when it was expecting to see an operator,
it gives you this warning. Usually it indicates that an operator or
delimiter was omitted, such as a semicolon.

(Missing operator before t?)
Unquoted string "lines" may clash with future reserved word at script_chkr line
51 (#3)
..."

Why is this failing? The comments shouldn't cause a script to fail should they?
All help in getting around this little issue greatly appreciated.

Thank you for your help.

-J
 
I suspect the problem is an unmatched single quote. Notice that line 49 contains a single quote. If a single quote is not closed before line 49, then line 49 is no longer ignored. The following code shows the problem.

$a = '
#characters: (`'"{}[]()). Something along the lines of a "grep -c" here
';

perl -c outputs the same error about the '#characters' line.

 
Thanks Raider2001.

So a single quote in a comment will cause a Perl script to fail? I thought the whole reason for using the #... was to exclude whatever follows the # on the same line from examination by the compiler.
I suppose I can alter the comment and use the words "quotes," "brackets," and "parantheses," and also change "won't" to would not to get around this. I'm just amazed that this is necessary at all.
 
No. You can put whatever you want in a comment. The problem is that line 49 is NOT a comment line. Note that "#" is no longer a comment character if it is enclosed by single-quotes. If you remove line 49, you should get another syntax error later in your program. Try moving line 49 earlier in the program, until you find the problem.

Good Luck
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top