Perl code that won't work with Embperl 
Author Message
 Perl code that won't work with Embperl

Can anyone kindly explain why the following Perl code, which works
fine when not used with Embperl, produces a seemingly nonsensical
error when run while using Embperl?  

open(FOO, "/home/nobody/all-tables");
while ($TextIn=<FOO>) {
    ($x,$x1,$x2) = split (/\|/,$TextIn);    
    ($fiz) = $x =~ m/^\s([a-z]+)/g;
    if ($fiz ne "") {

   }

Quote:
}

close(FOO);

The following error message is produced.

   [723]ERR: 24: Line 57: Error in Perl code: syntax error at
   /home/www/apache/htdocs/med-search1a.epl line 65, near "=) "
   syntax error at /home/www/apache/htdocs/med-search1a.epl line 73,
   near "}

   close"

I've ascertained that the open call is working (well, it appaers to be
anyway!); it returns a 1. The file exists and is readable by user
nobody.  If I comment out the while loop, or even just the line
containing "while (..." and the bracket that ends this loop, the error
message goes away.

Am I doing something wrong?

If it makes any difference, I'm using the latest non-beta version of
Embperl, Perl 5.005, and mod_perl.

--
Copyright (C) 2001 R. D. Davis    Ancient guru who see future once say:
All Rights Reserved               "wise man who meditate upon immortal wisdom

http://www.*-*-*.com/ ;    man" will enjoy interesting life."



Sat, 06 Sep 2003 14:48:41 GMT  
 Perl code that won't work with Embperl


Quote:
>open(FOO, "/home/nobody/all-tables");
>while ($TextIn=<FOO>) {
>    ($x,$x1,$x2) = split (/\|/,$TextIn);    
>    ($fiz) = $x =~ m/^\s([a-z]+)/g;
>    if ($fiz ne "") {

>   }
>}
>close(FOO);

>The following error message is produced.

>   [723]ERR: 24: Line 57: Error in Perl code: syntax error at
>   /home/www/apache/htdocs/med-search1a.epl line 65, near "=) "
>   syntax error at /home/www/apache/htdocs/med-search1a.epl line 73,
>   near "}

>   close"

This is a totally wild guess, but if the line giving you trouble is

    while ($TextIn=<FOO>) {

and the parser says it saw "=)", then it looks as if something
(EmbPerl? Something else in Apache processing the file before/after
EmbPerl?) is removing the "<FOO>". Something that thinks it's an HTML
tag? Does the error persist if you (just for debugging's sake) used an
IO::Handle and got rid of the angle brackets?

Marcel

--
We are Perl. Your table will be assimilated. Your waiter will adapt to
service us. Surrender your beer. Resistance is futile.
 -- London.pm strategy aka "embrace and extend" aka "mark and sweep"



Sun, 07 Sep 2003 22:44:02 GMT  
 Perl code that won't work with Embperl

Quote:
> Can anyone kindly explain why the following Perl code, which works
> fine when not used with Embperl, produces a seemingly nonsensical
> error when run while using Embperl?  
> open(FOO, "/home/nobody/all-tables");
> while ($TextIn=<FOO>) {
>     ($x,$x1,$x2) = split (/\|/,$TextIn);    
>     ($fiz) = $x =~ m/^\s([a-z]+)/g;
>     if ($fiz ne "") {

>    }
> }
> close(FOO);

Almost at the end of the documentation for HTML::Embperl (search
for "spaceship") there is a discussion about the use of '<' and '>';
basically Embperl treats the spaceship operator <> as an HTML tag
and removes it. The docs suggest a couple of ways around this. You
might also want to look at the discussion, about midway through
HTML::Embperl, about Embperl's metacommands for setting up things
like while loops.

best regards,
randy kobes



Mon, 08 Sep 2003 02:25:15 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Help me

2. open MAIL - code won't work

3. basic code -- why won't it work??!!

4. Apache, embperl, mod_perl : require doesn't work and can't write to file

5. Embperl won't make

6. HTML::Embperl::Execute won't recognise imported subroutines

7. DAO Installation workaround

8. I'm looking for a good code editor for PERL for Win NT

9. Announce: Embperl 0.11-beta - embed perl code in html files

10. Functional Perl code that fails with Embperl

11. Delphi und lange Spaltennamen unter ACCESS

12. my gif's won't work after copying them

 

 
Powered by phpBB® Forum Software