Perl and packge

Discussion in 'Perl Misc' started by cvrèak, Oct 7, 2009.

  1. cvrèak

    cvrèak Guest

    Hy,

    Can somebody explain me when use *.pm files and when uses *.pl?

    must be classes in *.pm files?
    cvrèak, Oct 7, 2009
    #1
    1. Advertising

  2. cvrèak

    Bart Lateur Guest

    cvrèak wrote:

    >Can somebody explain me when use *.pm files and when uses *.pl?


    Will this do?

    http://perldoc.perl.org/perlmod.html


    In short: there are two ways to specify files to load (require): the
    special package syntax (Foo::Bar), and the plain (Unix) file path
    format: "Foo/Bar.pm". The former is a special syntax that is recognized
    as syntactic sugar for the latter, but only in source code. If you
    specify the file as a string, or in a (scalar) variable, you *must* use
    the file path format.

    That's one way in which ".pm" special as a file extension. The second is
    that with "use", Perl will treat Foo::Bar both as a file name (after
    conversion), and as a package/class name, for which it will try to do a
    "import" class method call. That's the main reason for which module
    names and package names are commonly the same.

    >must be classes in *.pm files?


    No.

    Classes are defined as packages, and package declarations can be in any
    type of source files. See above as to why package and file name are
    usually the same. But it's not uncommon to have extra (utility) packages
    in the same source file.

    --
    Bart.
    Bart Lateur, Oct 8, 2009
    #2
    1. Advertising

  3. cvrèak

    cvrèak Guest

    thanks
    cvrèak, Oct 9, 2009
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. dpackwood
    Replies:
    3
    Views:
    1,784
  2. PerlFAQ Server

    FAQ 1.4 What are Perl 4, Perl 5, or Perl 6?

    PerlFAQ Server, Jan 23, 2011, in forum: Perl Misc
    Replies:
    0
    Views:
    294
    PerlFAQ Server
    Jan 23, 2011
  3. PerlFAQ Server
    Replies:
    0
    Views:
    673
    PerlFAQ Server
    Feb 3, 2011
  4. PerlFAQ Server

    FAQ 1.4 What are Perl 4, Perl 5, or Perl 6?

    PerlFAQ Server, Feb 27, 2011, in forum: Perl Misc
    Replies:
    0
    Views:
    289
    PerlFAQ Server
    Feb 27, 2011
  5. Dilbert
    Replies:
    0
    Views:
    840
    Dilbert
    Nov 10, 2011
Loading...

Share This Page