Ask a Question related to PERL Miscellaneous, Design and Development.
-
Rodney #1
Matching { } braces ???
In the example below, I'm testing if a string contains either the { or }
braces. The problem is that it is causing me a syntax error. The { on the
end of line #1 is pairing with the } on line #11 that is within the
=~m/\}/ pattern search.
Can anyone explain how to avoid this?
-------------------------------------------------------
#1 if ($bodytest_line =~ m/\{/) {
#2 $StartBraceComment = 1;
#3 $bodyTextLen = length($bodytest_line);
#4 $bodyLineCommentStartPos = index($bodytest_line, "{");
#5 $bodyLineCommentText = substr($bodytest_line,
$bodyLineCommentStartPos, $bodyTextLen);
#6 $bodyLineCommentText = "<I><Font
COLOR=$CommentColor>$bodyLineCommentText";
#7 $bodyLineNotCommentText = substr($bodytest_line, 0,
$bodyLineCommentStartPos);
#8 $bodyLineNotCommentText =
&OpalKeywords($bodyLineNotCommentText);
#9 $bodyLineNotCommentText =
&OpalQuotedText($bodyLineNotCommentText);
#10
#11 if ($bodyLineCommentText =~ m/\}/) {
#12 $bodyLineCommentText2Len = length($bodyLineCommentText);
#13 $bodyLineCommentEndPos2 = index($bodyLineCommentText,
"}");
#14 $bodyLineCommentText2 = substr($bodyLineCommentText,
0, $bodyLineCommentEndPos2);
#15 $bodyLineCommentText2 =
"$bodyLineCommentText</FONT></I>";
#16 $StartBraceComment = 0;
#17 }
#18 }
Thanks,
--
....
`·.¸¸.·´¯`·.¸¸.·´¯`·-> rodney
Rodney Guest
-
Contribute is converting curly braces upon editing
The HTML has a meta tag inside which looks like this: {text here}. Upon opening the page in Contribute, the data is changed internally to %7btext... -
WebMethod works fine until it hits the closing braces - throws System.StackOverflowException
Hi, I am getting System.StackOverflowException when calling a web method. The web method executes fine until it hits the closing braces that is... -
#22592 [Opn->Csd]: Cascading assignments to strings with curly braces broken
ID: 22592 Updated by: sniper@php.net Reported By: matteo at beccati dot com -Status: Open +Status: ... -
#22592 [Csd->Opn]: Cascading assignments to strings with curly braces broken
ID: 22592 Updated by: helly@php.net Reported By: matteo at beccati dot com -Status: Closed +Status: ... -
unicode in Image::Magick (hex values and braces problem?)
Eric Schwartz <emschwar@pobox.com> wrote in comp.lang.perl.misc: To mimic the OP's code perfectly it should only use every other character. Note... -
Purl Gurl #2
Re: Matching { } braces ???
Rodney wrote:
(snipped)
> In the example below, I'm testing if a string contains either the { or }
> braces. The problem is that it is causing me a syntax error. The { on the
> end of line #1 is pairing with the } on line #11 that is within the
> =~m/\}/ pattern search.> Can anyone explain how to avoid this?
C:\APACHE\USERS\TEST>perl -c test.pl
test.pl syntax OK
Purl Gurl
--
Kick Ass Perl Programming: [url]http://www.purlgurl.net[/url]
Purl Gurl Guest
-
Rodney #3
Re: Matching { } braces ???
Purl,
I'm editing using conTEXT... It has a PERL syntax highlighter built in.
When I paste the code I included ( as an example in the last post ) into
conTEXT and highlight one of the braces... it is suppose to show me the
matching brace by highlighting it too. This code is throwing it off.
Also... this code is part of a larger code write. The problem started when
I added the search for the { } braces. Now my error code tells me:
"Missing right curly or square bracket at
/u/web/XXXXXX/cgi-local/OPALconvert.pl line 485, at end of line
syntax error at /u/web/XXXXXXXX/cgi-local/OPALconvert.pl line 485, at EOF
/u/web/XXXXXXXX/cgi-local/OPALconvert.pl had compilation errors."
Note: line 485 is the last line. This indicates to me that the problem is
associated with the Braces.
Any help would be appreciated.
Thanks,
--
....
`·.¸¸.·´¯`·.¸¸.·´¯`·-> rodney
Rodney Guest
-
Godzilla #4
Re: Matching { } braces ???
Rodney wrote:
(snipped)> Purl,
> I'm editing using conTEXT... It has a PERL syntax highlighter built in.
> When I paste the code I included ( as an example in the last post ) into
> conTEXT and highlight one of the braces... it is suppose to show me the
> matching brace by highlighting it too. This code is throwing it off.
You are using the wrong colors for highlighting.
Try softer more feminine colors if you want
something to work right.
Purl Gurl
--
Most Intelligent Android To Be Found,
Roberta The Remarkable Robot.
[url]http://www.purlgurl.net/~callgirl/roberta/roberta.cgi[/url]
Godzilla Guest
-
Bob Walton #5
Re: Matching { } braces ???
Rodney wrote:
> Purl,
>
> I'm editing using conTEXT... It has a PERL syntax highlighter built in.
> When I paste the code I included ( as an example in the last post ) into
> conTEXT and highlight one of the braces... it is suppose to show me the
> matching brace by highlighting it too. This code is throwing it off.
>
> Also... this code is part of a larger code write. The problem started when
> I added the search for the { } braces. Now my error code tells me:
>
> "Missing right curly or square bracket at
> /u/web/XXXXXX/cgi-local/OPALconvert.pl line 485, at end of line
> syntax error at /u/web/XXXXXXXX/cgi-local/OPALconvert.pl line 485, at EOF
> /u/web/XXXXXXXX/cgi-local/OPALconvert.pl had compilation errors."
>
>
> Note: line 485 is the last line. This indicates to me that the problem is
> associated with the Braces.
....
Perl thinks your code as posted is fine (as regards compilation -- I
made no attempt to run it). Note that just because your editor's syntax
highlighting or brace searching screwed up doesn't necessarily mean
there is anything wrong with your code. There is a saying that "only
Perl can parse Perl".
Here is a simple piece of standalone code which illustrates the same
problem and also shows that Perl parses, compiles and executes it fine:
$_="{}";
if(/{/){
print "1match\n";
if(/}/){
print "2match\n";
}
}
If it is any consolation, VIM's color syntax highlighting highlights
correctly, but its brace-matching ability suffers the same problem your
editor has.
Regarding the problem with your larger piece of code, I suggest you look
in it rather than the piece you posted, as the problem is probably
somewhere in the other code. You can check brace matching by snipping
pieces out and running perl -c on them.
--
Bob Walton
Bob Walton Guest
-
James Willmore #6
Re: Matching { } braces ???
On Fri, 12 Sep 2003 21:45:32 -0400
"Rodney" <NoSpamPlease@bellsouth.net> wrote:
<snip>> In the example below, I'm testing if a string contains either the {
> or } braces. The problem is that it is causing me a syntax error.
> The { on the end of line #1 is pairing with the } on line #11
> that is within the=~m/\}/ pattern search.
>
> Can anyone explain how to avoid this?
Read ...
perldoc perlstyle
It works not just for Perl, but other languages as well (such as bash,
C++, Java, PHP, or, dare I say, C-shell).
I read your other post about using an IDE for Perl. Maybe you need to
configure it to fall in line with the accepted style that Perl has put
forth. More importantly, have you tried to edit the script in
something other than an IDE, applying what you applied from the style
guide?
And, as Purl Gurl suggested, run with the script with syntax checking:
perl -c <script name here>
The number one error that crops up in programming is the dreded syntax
error. The style guide will assist you in mimimizing the number you
encounter.
HTH
--
Jim
Copyright notice: all code written by the author in this post is
released under the GPL. [url]http://www.gnu.org/licenses/gpl.txt[/url]
for more information.
a fortune quote ...
In seeking the unattainable, simplicity only gets in the way.
-- Epigrams in Programming, ACM SIGPLAN Sept. 1982
James Willmore Guest
-
Eric J. Roode #7
Re: Matching { } braces ???
Bob Walton <bwalton@rochester.rr.com> wrote in
news:3F62A4D4.30607@rochester.rr.com:
Actually, the saying is "Only perl can parse Perl." Subtle difference.> ... There is a saying that
> "only Perl can parse Perl".
--
Eric
$_ = reverse sort $ /. r , qw p ekca lre uJ reh
ts p , map $ _. $ " , qw e p h tona e and print
Eric J. Roode Guest
-
Tad McClellan #8
Re: Matching { } braces ???
James Willmore <jwillmore@cyberia.com> wrote:
> The number one error that crops up in programming is the dreded syntax
> error.
In the universe of all potential programmer's errors, a
"syntax error" is the *most welcome* of all possible errors!
Because they are the easiest to find. So easy that even a
machine can find them.
It is those pesky "semantic errors" that are dreaded.
--
Tad McClellan SGML consulting
[email]tadmc@augustmail.com[/email] Perl programming
Fort Worth, Texas
Tad McClellan Guest
-
James Willmore #9
Re: Matching { } braces ???
On Sat, 13 Sep 2003 09:28:07 -0500
[email]tadmc@augustmail.com[/email] (Tad McClellan) wrote:True. I sit corrected - too lazy to stand ;)> James Willmore <jwillmore@cyberia.com> wrote:
>>> > The number one error that crops up in programming is the dreded
> > syntax error.
>
> In the universe of all potential programmer's errors, a
> "syntax error" is the *most welcome* of all possible errors!
>
> Because they are the easiest to find. So easy that even a
> machine can find them.
>
> It is those pesky "semantic errors" that are dreaded.
--
Jim
Copyright notice: all code written by the author in this post is
released under the GPL. [url]http://www.gnu.org/licenses/gpl.txt[/url]
for more information.
a fortune quote ...
It wasn't that she had a rose in her teeth, exactly. It was more
like the rose and the teeth were in the same glass.
James Willmore Guest
-
Rodney #10
Re: Matching { } braces ???
Thanks all.
I found the problem. It was a faulty set of braces that "I" did... not a
PERL issue.
I made the mistake of writing a lot of code without testing it as I went
along. I was starting to get that "this will never work" feeling.... but I
couldn't stop writing because I had to get the code out of my head.
As I suspected.... deep in the bowels of that code was errant syntax.
I ended up having to REM out everything... then add it back in... 1 piece at
a time, until it blew up.
I lesson I "thought" I learned several times before. :(
Thanks again for your help.
--
....
`·.¸¸.·´¯`·.¸¸.·´¯`·-> rodney
Rodney Guest



Reply With Quote

