Found a way to write modules without package, export

Discussion in 'Perl Misc' started by Great Deals, Sep 24, 2003.

  1. Great Deals

    Great Deals Guest

    First, copy and paste all subs into a file named something.pm then add
    1; to the end of something.pm
    No need of export or package
    Isn't that great? Why would people even use package/export?

    In main program something.pl, write use something

    something.pm:
    sub getit2{
    return time;
    }

    1;

    something.pl:
    #!/usr/bin/perl -w
    use something;

    $ab= getit2;
    print "$ab\n";
    Great Deals, Sep 24, 2003
    #1
    1. Advertising

  2. Great Deals

    Anno Siegel Guest

    Great Deals <> wrote in comp.lang.perl.misc:
    > First, copy and paste all subs into a file named something.pm then add
    > 1; to the end of something.pm
    > No need of export or package


    What made you think you need "package", or Exporter.pm, to put subs into
    another file? Of course you can do that. The result is not a Perl module,
    however. That part of your subject is wrong.

    > Isn't that great? Why would people even use package/export?


    Go ahead and use it for a while. You'll discover the advantages of
    name spaces and their separation quite on your own.

    [code snipped]

    Anno
    Anno Siegel, Sep 24, 2003
    #2
    1. Advertising

  3. Great Deals

    peter pilsl Guest

    Great Deals wrote:

    >
    > Isn't that great? Why would people even use package/export?
    >


    modules grant you some kind of privacy for the code you put into this
    module. You can easily split up big projects into several modules without
    having to fear namespace-collisions. This will get even more important if
    you want to offer your module to various applications/authors and use
    OO-approaches.

    You just split your code into several files, but dont split the underlying
    structure.

    peter


    --
    peter pilsl

    http://www.goldfisch.at
    peter pilsl, Sep 24, 2003
    #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. =?Utf-8?B?RGF2aWQgVmFsbGU=?=

    Invalid export DLL or export format

    =?Utf-8?B?RGF2aWQgVmFsbGU=?=, Oct 29, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    3,598
    =?Utf-8?B?RGF2aWQgVmFsbGU=?=
    Oct 29, 2003
  2. Maarten van Reeuwijk

    Newbie: how to write modules without C

    Maarten van Reeuwijk, Jan 15, 2004, in forum: Python
    Replies:
    2
    Views:
    270
    Maarten van Reeuwijk
    Jan 15, 2004
  3. Dave
    Replies:
    2
    Views:
    455
  4. lkcl
    Replies:
    4
    Views:
    215
  5. Maarten Porters
    Replies:
    1
    Views:
    414
    Florian Gilcher
    Jul 28, 2008
Loading...

Share This Page