Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!stanford.edu!agate!usenet.ins.cwru.edu!ncoast!allbery From: allbery@NCoast.ORG (Brandon S. Allbery KF8NH) Newsgroups: comp.lang.perl Subject: Re: strange (IMHO) eval behavior Message-ID: <1991Jun3.230747.8951@NCoast.ORG> Date: 3 Jun 91 23:07:47 GMT References: Reply-To: allbery@ncoast.ORG (Brandon S. Allbery KF8NH) Followup-To: comp.lang.perl Distribution: comp Organization: North Coast Public Access Un*x (ncoast) Lines: 32 As quoted from by mayer@sono.uucp (Ronald &): +--------------- | % perl -e '@a = eval ("*\n"); print "@a\n";' | [A bunch of random control characters which don't mean anything to me.] | | % perl -e '@a = eval ("*\n"); print "@a";' | *main' | | My guess: It's probably somehow related to this section of the manual, | but I can't figure out how or why: | > Since a *name value contains unprintable binary data, if it | > is used as an argument in a print, or as a %s argument in a | > printf or sprintf, it then has the value '*name', just so it | > prints out pretty. +--------------- You are eval'ing something which Perl treats as an expression: a "type-glob" (or whatever the name du jour is) on the variable named "\n". (Which is illegal in most circumstances; it should be here as well. This is probably a bug.) So in the second case (easiest), you're getting back from print that it saw a *-expression on the variable "\n" (newline) in package main. The first example is more interesting: since the \n in the print causes an interpolation (the second is probably optimized out), print can't recognize that it was passed an *-expression and therefore prints out the actual symbol table entry: a binary value which is meaningless to mere mortals. ++Brandon -- Me: Brandon S. Allbery KF8NH: DC to LIGHT! [44.70.4.88] Internet: allbery@NCoast.ORG Delphi: ALLBERY uunet!usenet.ins.cwru.edu!ncoast!allbery