Bug in Perl 5, or is it me? 
Author Message
 Bug in Perl 5, or is it me?

Perl 5 is generating a warning that doesn't make sense to me.

   % cat test.pl

   % perl test.pl                    <<<this is Perl 4.036

   % perl5 test.pl
   String found where operator expected at test.pl line 3, near ""message\n""

As you can see, Perl 4 was quite happy, but Perl 5 appears to be expecting
a comma after STDERR.  (If I put in a comma, Perl 4 outputs nothing,
whereas Perl 5 outputs "STDERRmessage").  The following does not generate
any warnings:

   print( STDERR



exhibits the problem.  And

   print STDERR

works fine.  So it seems to make a difference whether STDERR is on the
same line with "print" or not.  (And I thought this was Perl, not shell.)

I figure it's the object-method syntax that is complicating matters,
because the other time I have seen a similar message is when I have said

   Method( $obj $arg1, $arg2 );

instead of

   Method $obj $arg1, $arg2;

which I thought were equivalent.

In the object-method case, it also gets a syntax error, like this:

   Scalar found where operator expected at filename line 32, near "$obj $arg1"
   syntax error at filename line 32, near "$obj $arg1"
   Execution of filename aborted due to compilation errors.

If I put a comma after $obj,  as in

   Method( $obj, $arg1, $arg2 );

Perl 5 then doesn't realise it is an object method, and says

   Undefined subroutine &main::Method called at filename line 32.

(here we are in the 'main' package and have imported the object package's
namespace, including &Method).  I can see why it might behave this way,
but it seems unnecessarily restrictive.

Is there a bug in the parsing of subroutine/object-method calls, or do I just
not properly understand what's going on?  (I've RTFM, so maybe it's time to
Use the Source).


56 Kennedy Street, Maylands WA 6051, Australia
Phone/Fax +61 9 272 5061

U N I X   A N D   O P E N   S Y S T E M S
   Configuration      Technical Writing
     Networking        Troubleshooting
Software Development      Training

Thu, 17 Jul 1997 12:26:53 GMT  
 [ 1 post ] 

 Relevant Pages 

1. A bug...or am I screwy?

2. Am I really confused or is this a BUG (4.036)

3. Need Perl help, but I am not a Perl Monger

4. Activestate Perl Bug #23103 Ptk dowhenidle/fileevent bug

5. ppm fails now that I am on perl 5.6

6. newbie-perl or why am i blind to this simple

7. I am a perl beginner

8. Why I am glad I know perl

9. I am looking for PERL compiled for Apollo

10. Am curious about perl

11. Am I in the perl Debugger?

12. I am a Perl Newbie.....need some help please


Powered by phpBB® Forum Software