Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!emory!gatech!mcnc!uvaarpa!mmdf From: worley@compass.com (Dale Worley) Newsgroups: comp.lang.perl Subject: Variable output formats Message-ID: <1990Dec12.214612.6109@uvaarpa.Virginia.EDU> Date: 12 Dec 90 21:46:12 GMT Sender: mmdf@uvaarpa.Virginia.EDU (Uvaarpa Mail System) Reply-To: worley@compass.com Organization: The Internet Lines: 25 To get a variable output format, you have to construct the format definition as a string and 'eval' it. For instance, $myformat = '@<<<<<<<@<<<<<<<<<<<<@<<<<<<<<<<<<@<<<<<<<<<<<@<<<<<<<<<<'; eval " format STDOUT = $myformat \$ARGV[0],\$ARGV[1],\$ARGV[2],\$ARGV[3],\$ARGV[4] . "; write STDOUT; If you run this program, it prints its first five arguments with the format in $myformat. (Remember that the final '.' must be followed by a newline, or the format definition is syntactically invalid and will not take effect.) Dale Dale Worley Compass, Inc. worley@compass.com -- It's okay to crave approval ... isn't it?