Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!wuarchive!usc!zaphod.mps.ohio-state.edu!tut.cis.ohio-state.edu!ucbvax!pasteur!agate!sunkist!raymond From: raymond@sunkist.berkeley.edu (Raymond Chen) Newsgroups: comp.lang.perl Subject: formats inside an eval Message-ID: <1990Mar21.073635.25523@agate.berkeley.edu> Date: 21 Mar 90 07:36:35 GMT Sender: usenet@agate.berkeley.edu (USENET Administrator;;;;ZU44) Reply-To: raymond@math.berkeley.edu (Raymond Chen) Organization: U.C. Berkeley Lines: 31 My perl man page says eval EXPR EXPR ... is executed in the context of the current perl program, so that any variable settings, subroutine or format definitions remain afterwards. Now everybody uses eval for dynamic variable settings and subroutines, so I figured, hey, why not dynamic formats? % cat foo eval "format = An on-the-fly format. . "; print "Error: $@\n"; % perl foo (Patchlevel 12) Error: syntax error in file (eval) at line 2, next 2 tokens "= An" Changing "format =" to "format STDOUT =" didn't seem to help any. The usual concluding sentences: Am I doing something wrong? If I'm not in error, has this been fixed in a recent patch? sub _{print shift;"&_('@_')";}$"="','";$_=&_(split(//,"Not another perl hacker,"));$_=eval while!/''/; -- raymond@math.berkeley.edu "And perl pulls ahead of C, but APL still has a commanding lead..." --- play-by-play of the `Most closely approximates line noise' competition