[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] syntax barriers?



> > Can you improve the "[]" solution or even find the perfect "syntax/error
> > barrier"?
> > 
> 
> How about:
> eval qq{\n# line 40 "hulla"\n$user_code};

well, while this is a nice solution, it isn't really solving the problem
(obviously, there is an eval "" outside all this code, so this is
mitigating the problem one level into the code, but really a solution).
my only grief with that is that i have to duplicate the ugly code around
the eval that ensure that the context for the eval is set correctly, that
exceptions propagate correctly (and perl does not crash) and lastly there
are some issues with eval and utf8 ;)

On Sun, May 13, 2001 at 01:55:35AM +0100, Michael G Schwern <schwern@pobox.com> wrote:
> Write the user code out to a seperate file and use 
> 
>         eval{ do($user_file) };
>         warn $@ if $@;

now this is cool! however, a temporary file.... ;)

On Sun, May 13, 2001 at 09:36:10AM +0300, Ilmari Karonen <iltzu@sci.fi> wrote:
> Or you could just use string eval and heredocs:
> 
> eval <<'STRING_THAT_IS_NOT_A_LINE_IN_USER_CODE'; die $@ if $@;

similar problem: the eval (that is hidden inside the "do $path" as well)
si the one thing that shouldn't be allowed in a solution. obviously,
seperating the string into many substrings (which is possible since each
eval should be a valid BLOCK) and eval'ing them seperately would always work
- however, then I wouldn't need to ask ;)

> (Random observation: To be really careful, remember to strip linefeeds
> and double quotes from filenames before using them in #line comments..)

;) indeed ;)

thanks a lot for your input!

-- 
      -----==-                                             |
      ----==-- _                                           |
      ---==---(_)__  __ ____  __       Marc Lehmann      +--
      --==---/ / _ \/ // /\ \/ /       pcg@goof.com      |e|
      -=====/_/_//_/\_,_/ /_/\_\       XX11-RIPE         --+
    The choice of a GNU generation                       |
                                                         |

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe