Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Your usages have subtly different semantic, and in some cases, practical meanings, especially if you're using Perl 5.14 or newer.

{ package somename; ..... }: This creates a lexical scope, and inside that lexical scope you happen to be working with package somename. When the block ends, you will be working back in the previous package again, though this is not the preferred syntax (see below) as of Perl 5.14.

package somename; { ..... }: This declares that you're working with package somename, and then creates a lexical scope. The two are not really related to each other, but it does happen that this lexical scope was created while you're working in package somename.

package somename { ..... }: This is a new Perl 5.14 feature; you've declared that you'll be using package somename for the duration of the following block (I suppose you could change within the block, but haven't tried). Once the block expires, the package you will find yourself working within will revert back to whatever was in effect before this package block.(See

The next two are just the same as other constructs you demonstrated, but with an extra semicolon at the end, which has no effect. You can put a semicolon just about anywhere you want as long as it doesn't break a statement. print "hello world\n" ;;;;;;;;;;;;; print "Hello again\n";;;;;; # Perfectly legal

The last one is a syntax error because you didn't separate the "package somename" statement from the next statement with a semicolon. It's not a syntax error if that statement is the last statement within the block, since semicolons are optional for the final statement in a block.


In reply to Re: OO Perl Baby Steps by davido
in thread OO Perl Baby Steps by Clovis_Sangrail

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others browsing the Monastery: (6)
    As of 2018-07-23 10:19 GMT
    Find Nodes?
      Voting Booth?
      It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?

      Results (463 votes). Check out past polls.