[comp.lang.perl] two possible bugs

marc@athena.mit.edu (08/09/90)

Possible Bug 1:

This program:

    #!/mit/watchmaker/@sys/perl

    sub foo {
	    local($bar);

	    $_[0] = "frep";
	    print "\$bar = \"$bar\"\n";
    }

    $bar = "string";
    &foo($bar);
    print "\$bar = \"$bar\"\n";

prints:

    $bar = "frep"
    $bar = "string"

This is, at best, confusing.  What is it doing, and is it a bug?
What's it supposed to do?

Possible bug 2:

perl man page (pl 18):

     sprintf(FORMAT,LIST)
             Returns a string formatted by the usual printf con-
             ventions.  The * character is not supported.

printf/sprintf man page (BSD 4.3, possibly enhanced locally)

     Each conversion specification is introduced by the character
     ``%''.  The remainder of the conversion specification
     includes in the following order:

     +    Zero or more of the following flags:

	...

          -    A blank which specifies that a blank is to precede
               any non-negative value in d, e, E, f, g, or G
               conversion.

C program:

    main()
    {
	    printf("\"% f\"\n",3.1416);
    }

C output:

    " 3.141600"

perl script:

    #!/mit/watchmaker/@sys/perl
    printf("\"% f\"\n",3.1416);

perl output:

    ""
    f"

The C and perl outputs obviously do not match.  In any case, I have no
clue how the perl output comes from the script I gave it.  Again,
what's happening?  I'm pretty sure that this is a bug, and that the C 
and perl outputs should match.

		Marc