Re: Unmatched right curly bracket ...
by Biker (Priest) on Feb 27, 2002 at 11:04 UTC
|
Are you building complex strings?
You may have an unmatched string, like starting with a double quote and ending what you think is the same string with a single quote.
Everything will go worng!
| [reply] |
|
|
Bad name after %s::
message with 5.6.1
/J\ | [reply] [d/l] |
Re: Unmatched right curly bracket ...
by simon.proctor (Vicar) on Feb 27, 2002 at 11:10 UTC
|
Perhaps if you put your code on your scratchpad? Then we could take a look at it.
I'll take a peek if you message me (or reply here) that you have put it there.
UPDATE
Heres my code which appears to work. Note that I have quoted the ENDHTML bits. Take a look at perlfaq4:
Check for these three things:
There must be no space after the << part.
There (probably) should be a semicolon at the end.
You can't (easily) have any space in front of the tag
And the code:
use strict;
use warnings;
use vars qw($home_fax $Company $position $company_address1 $company_po
+stal1 $company_phone $company_fax);
$home_fax = "a";
$Company = "b";
$position = "c";
$company_address1 = "d";
$company_postal1 = "e";
$company_phone = "f";
$company_fax = "g";
section2();
sub section2
{
print <<"ENDHTML";
one
ENDHTML
unless ($home_fax eq "")
{
print <<"ENDHTML";
two
ENDHTML
}
print <<"ENDHTML";
three
ENDHTML
unless ($Company eq "")
{
print <<"ENDHTML";
four
ENDHTML
}
unless ($position eq "")
{
print <<"ENDHTML";
five
ENDHTML
}
unless ($company_address1 eq "")
{
print <<"ENDHTML";
six
ENDHTML
}
unless ($company_postal1 eq "")
{
print <<"ENDHTML";
seven
ENDHTML
}
unless ($company_phone eq "")
{
print <<"ENDHTML";
eight
ENDHTML
}
unless ($company_fax eq "")
{
print <<"ENDHTML";
nine
ENDHTML
}
print <<"ENDHTML";
ten
ENDHTML
}
Which prints:
C:\WINNT\PROFILES\simonp\DESKTOP>perl test.pl
one
two
three
four
five
six
seven
eight
nine
ten
C:\WINNT\PROFILES\simonp\DESKTOP>
I hope that helps :). | [reply] [d/l] [select] |
|
|
Here is the code, I decided to take the Html out to make it less unwieldly...
sub section2
{
print <<ENDHTML;
# Html goes in here
ENDHTML
unless ($home_fax eq ""){
print <<ENDHTML;
# Html goes in here
ENDHTML
}
print <<ENDHTML;
# Html goes in here
ENDHTML
unless ($Company eq "")
{
print <<ENDHTML;
# Html goes in here
ENDHTML
}
unless ($position eq "")
{
print <<ENDHTML;
# Html goes in here
ENDHTML
}
unless ($company_address1 eq "")
{
print <<ENDHTML;
# Html goes in here
ENDHTML
}
unless ($company_postal1 eq ""){
print <<ENDHTML;
# Html goes in here
ENDHTML
}
unless ($company_phone eq "")
{
print <<ENDHTML;
# Html goes in here
ENDHTML
}
unless ($company_fax eq "")
{
print <<ENDHTML;
# Html goes in here
ENDHTML
}
print <<ENDHTML;
# Html goes in here
ENDHTML
}
Cheers, Gerard.
| [reply] [d/l] |
|
|
| [reply] |
|
|
|
|
I know I am not addressing your question, but why use unless when you are checking for truth values?
I'd rather use if:
if ($company_fax) {
....
}
instead of:
unless ($company_fax eq "")
....
}
/prakash | [reply] [d/l] [select] |
Re: Unmatched right curly bracket ...
by gellyfish (Monsignor) on Feb 27, 2002 at 11:06 UTC
|
I know its like shutting the stable door and everything but perhaps you ought to be using an editor like vim that lets you match the brackets /J\
| [reply] |
Re: Unmatched right curly bracket ...
by erikharrison (Deacon) on Feb 28, 2002 at 02:36 UTC
|
I'm not sure from the preceeding replies that you have solved the problem . . .but even if you have this is good to keep in mind.
I once stared at this subroutine for *5* hours trying to figure out where the missing curlie was . . .and eventually I found it. My problem? A missing curlie several hundred lines before - because my subs are generally at the end of a file, perl managed to parse the whole thing not finding the "missing curlie" error until the last couple of lines. Using the debugger would have helped had I known at the time how to use it. But keep in mind that, like run away lines and strings, missing curlies often creat errors at a distance - far more distance than any other error I've encountered.
Cheers,
Erik
| [reply] |
|
|
Yikes. 5 hours! In the interest of saving you the hassle next time, might I recommend perltidy? The perltidy documentation shows how it helps find mis-matched braces at: An example of finding a nesting error (here it is in googles cache since the above link isn't working for me at the moment.)
-Blake
| [reply] |
|
|
Thanks all for your comments. I manageed to solve it in the end, by removing my sloppy, trailing spaces. Erik, I did already think of that, I ran the subroutine as seperate file altogether and got the same error, which is how I knew it was in there. Thanks anyway.
Regards,
Gerard.
| [reply] |