Path: utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!snorkelwacker!tut.cis.ohio-state.edu!oz.cis.ohio-state.edu!jgreely From: jgreely@oz.cis.ohio-state.edu (J Greely) Newsgroups: comp.lang.perl Subject: Re: formats inside an eval Message-ID: Date: 21 Mar 90 10:01:34 GMT References: <1990Mar21.073635.25523@agate.berkeley.edu> Sender: usenet_news@tut.cis.ohio-state.edu Reply-To: J Greely Organization: Ohio State University Computer and Information Science Lines: 32 In-reply-to: raymond@sunkist.berkeley.edu's message of 21 Mar 90 07:36:35 GMT In article <1990Mar21.073635.25523@agate.berkeley.edu> raymond@sunkist.berkeley.edu (Raymond Chen) writes: >Now everybody uses eval for dynamic variable settings and subroutines, >so I figured, hey, why not dynamic formats? Larry will probably explain this one in greater detail, but the short version is that it just doesn't work. Note that you can use 'do' to accomplish what you want: &feval(<<'EOF'); format= @|| $foo . EOF $foo="X"; write; sub feval { local($format,$tempfile) = (@_,"/tmp/feval.$$"); open(tempfile,">$tempfile") || die "$tempfile: $!\n"; print tempfile $format; close(tempfile); do $tempfile; die "feval: $@" if $@; unlink($tempfile); } Now all we need is an easy way to capture the output of a write. Maybe a companion named "swrite"? -- J Greely (jgreely@cis.ohio-state.edu; osu-cis!jgreely)