Perl and $#

Barry Friedman friedman at chekov.UU.NET
Fri Dec 29 01:25:31 AEST 1989


I am running perl v3.0 patchlevel 8 on an hp9000/840 system and
am getting some strange results using the $# variable. 
Conversions are inconsistant and linefeeds disappear.

Here's my test program:

	#!/usr/local/bin/perl

	$a = 1/3;
	print $a, "\n";
	print "$a\n";

	$#="%.3g"; # set numeric width

	# note lack of linefeeds in output
	print "$a\n";
	print "$a \n";
	print $a, "\n";  # this one puts out a linefeed

	#note incorrect conversion
	print "a= $a \n";

	print "$a" . "\n";  # no linefeed here
	print "\n";
	print $a,  "\n";    # but this puts one out
	print "a= $a \n";

And the output:

	0.33333333333333331
	0.33333333333333331
	0.3330.3330.333
	a= 0.33333333333333331 
	0.333
	0.333
	a= 0.33333333333333331 

Is this a bug or am I missing something?
-- 
Barry Friedman              UUCP: ...!uunet!chekov!friedman



More information about the Comp.sources.bugs mailing list