[comp.lang.perl] Output format problem -- pls help!

fingerhu@ircam.fr (Michel Fingerhut) (01/10/91)

I am trying to control the number of decimals in printed output without
using printf explicetely.  The simplest example:

	$[ = 1;                 # set array base to 1
	$, = ' ';               # set output field separator
	$\ = "\n";              # set output record separator
	$#= "%.2f";		# set output precision
	$k=1/3;
	print <<EOF
	$k
	EOF

prints 0.33.  However, if replacing the print with

	print <<EOF
	$k
	$k
	EOF

(e.g.), it prints

	0.33333333333333331
	0.33333333333333331

which is either incorrect or my wrong understanding.  However,

	print $k, $k;

works fine (0.33 0.33).

Can someone help please?