Only Frobnicate is accessible (& thus available as a superclass) externally.

Incorrect. Any external code which does a use Frobnicate will get access to all packages/classes within Frobnicate.pm. The relationship of "file name == package name" is purely a matter of convention. It is not enforced in any way by perl.

Let's create a module Foo.pm containing:

package Bar; sub identify { print "I'm in package " . __PACKAGE__ . "\n"; } 1;
and then write a program that says:
#!/usr/bin/perl use Foo; Bar->identify(); Foo->identify();
Running this program produces the output
I'm in package Bar Can't locate object method "identify" via package "Foo" (perhaps you f +orgot to load "Foo"?) at...
As you can see, Bar being named differently than the file it's in does not in any way reduce its visibility or accessibility to the outside world.

But don't do that in production code, of course. The reason for the convention is because use Foo giving you access to package Bar is confusing as hell, especially if it doesn't give access to package Foo.


In reply to Re^2: How to create nested class in perl? by dsheroh
in thread How to create nested class in perl? by sarojt72

Title:
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, details, 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, summary, 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.