Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

5.10.0 seems to break package

by lembark (Novice)
on Jul 10, 2009 at 19:49 UTC ( #779029=perlquestion: print w/replies, xml ) Need Help??

lembark has asked for the wisdom of the Perl Monks concerning the following question:

Nothing in perldelta describes this difference; can't find any ref's via google or search on 5.10/mulitple/package.

Oddity: with use v5.10.0 (in any of the stringy versions), a second package delivers a syntax error. For example, the code below fails with:

syntax error at line 6, near "package bar"

Adding semi-colons after the sub's allows the code to compile, but I don't remember seeing anything about semicolons being required after sub def's -- even ones before package declarations.

Or is there something else in the perldelta that I've missed?

use v5.10.0; package foo; foo {} package foo::bar; bar {} 1 __END_
so much for my editing skills -- sorry for wasting your time -- the original was frying itself with the subs in place.

Replies are listed 'Best First'.
Re: 5.10.0 seems to break package
by Joost (Canon) on Jul 10, 2009 at 20:00 UTC
    foo {} is a CALL to a function named foo, passing a hashref - not a function declaration. You need a semi-colon after a function call. update: well, most of the time - not at the end of a file or block, for example, but you do need one before starting a new package.

    You probably meant something like:

    package foo; sub foo {} package foo::bar; sub bar {}
    Note the subs.
Re: 5.10.0 seems to break package
by ikegami (Patriarch) on Jul 10, 2009 at 20:06 UTC
    Contrary to your implications, the missing "sub" tokens or semicolons (";") are also errors without the use line and in versions earlier than 5.10.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://779029]
Approved by Joost
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2022-12-07 06:29 GMT
Find Nodes?
    Voting Booth?

    No recent polls found