Home
TeamSite
javascript in .ipl
cliffhanger
Hi,
I am writing a perl script that checks whether some particular file resides in a directory, at the end of the file I am trying to define an onLoad event that calls one of my javascript methods. my .ipl file works fine individually, but when I added that 6 lines of HTML, it gives me compilation error!
This is what I added at the end of .ipl
line 44: <HTML>
45: <head>
46: <SCRIPT language = "javascript">
47: </SCRIPT>
48: </HEAD>
49: <BODY onLoad="opener.top.getScriptFrame().setValue($fileExists)"/>
50: </HTML>
It gives me the following error:
Bareword found where operator expected at FileExists.ipl line 48, near "</head"
(Might be a runaway multi-line // string starting on line 47)
(Missing operator before head?)
Semicolon seems to be missing at FileExists.ipl line 50.
syntax error at FileExists.ipl line 45, near "head>"
Execution of FileExists.ipl aborted due to compilation errors.
What am I missing here?
Thanks a lot folks!
-cliffhanger
Find more posts tagged with
Comments
Dwayne
HTML is not valid perl.
If what you meant to do was to print that HTML code out to STDOUT (I'm assuming that this code is run as a CGI, correct?), then you just need to wrap the whole thing inside of a prrint statement. Something like this:
print <<EOF;
You could also use the
qq
construct, instead of using a HERE document (
<<
)
--
Current project: TS 5.5.2/6.1 W2K
cliffhanger
Hi Dwayne,
I tried print <<EOT, yet it gave me the same error. But when I used <<EOF according to your suggestion, it executed that file just fine!
Why didn't it recognize <<EOT?
Thanks^infinity!
-cliffhanger
Dwayne
I suspect that there was something else going on, as
EOT
should work just as well as
EOF
. Provided of course that you changed it in both places.
The other common mistake people make with 'here' documents is to forget the semicolon (
;
) after the
<<ZZZ
;
. If you left that off, you'd also see that error.
--
Current project: TS 5.5.2/6.1 W2K
Adam Stoller
... and the other common mistake made (which is why I tend to dislike them) is if the ending tag (EOF, EOT, whatever) gets indented - it won't work correctly unless you accounted for the exact amount of indent at the opening - e.g.:
print <<EOF;
hello
EOF
and
print <<" EOF";
hello
EOF
both work, but:
print <<EOF;
hello
EOF
results in something like
Can't find string terminator "EOF" anywhere before EOF at ...
.
I tend to prefer using qq() or join("\n", ...); to avoid this kind of problem.
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
cliffhanger
Hi ghoti,
You're right! your last mentioned error is what I made
Thanks, now I know
regarding the same problem, how do I check if that "onLoad" event is triggered? This is how my onLoad looks now:
<body onLoad = "somefunction()">
this somefunction() is between the script tags. To check if it ever gets there, I have some alert messages there, but it seems from the execution that my code is not making there....
would you have any guess why?