🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sources.bugs
Article #2291

Perl and $#

#2291
From: Barry Friedman
Date: Thu, 28 Dec 1989 14:25
40 lines
1385 bytes
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
Technical Details
Message-ID: <1630@bnr-rsc.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!rex!samsung!cs.utexas.edu!uunet!bnrgate!bnr-fos!bigsur!bnr-rsc!friedman

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!rex!samsung!cs.utexas.edu!uunet!bnrgate!bnr-fos!bigsur!bnr-rsc!friedman
From: friedman@chekov.UU.NET (Barry Friedman)
Newsgroups: comp.sources.bugs
Subject: Perl and $#
Summary: Inconsistant results with numeric output precision
Message-ID: <1630@bnr-rsc.UUCP>
Date: 28 Dec 89 14:25:31 GMT
Sender: news@bnr-rsc.UUCP
Reply-To: chekov!friedman@uunet.UU.NET (Barry Friedman)
Distribution: na
Organization: Northern Telecom, Ottawa, Canada
Lines: 40