Well, no - in fact, everything won't still work.

ben@Tyr:/tmp$ echo -e 'sub greet { "Hello, world!\\n" }\n1;' > hello.p +l ben@Tyr:/tmp$ perl -Mhello.pl -we'print greet' syntax error at -e line 0, near "use hello." Execution of -e aborted due to compilation errors. ben@Tyr:/tmp$ perl -Mhello -we'print greet' Can't locate hello.pm in @INC (@INC contains: /etc/perl /usr/local/lib +/perl/5.8.8 /usr/local/share/perl/5.8.8 /usr/lib/perl5 /usr/share/per +l5 /usr/lib/perl/5.8 /usr/share/perl/5.8 /usr/local/lib/site_perl /us +r/local/lib/perl/5.8.7 /usr/local/share/perl/5.8.7 .). BEGIN failed--compilation aborted.

As toolic pointed out, you can't load a '.pl' file as a module; you'd have to use "require" (or "do") instead of "use". Which opens up a very large can of worms.

Libraries are loaded at run-time; modules are loaded at compile time. This, in itself, is a huge difference that allows modules much, much more scope for action than libraries. "use Xyz" also imports the symbols and the semantics from package "Xyz" into the current one - not something that happens with "require Xyz.pl" (which just checks to see if Xyz.pl has already been loaded, updates %INC, and "wraps" a lexical scope block around the content of "Xyz.pl".)

Last of all, libraries are pretty much deprecated. They're a Bad Idea - at least, they've come to be seen as one - for a number of reasons (namespace conflicts, among other reasons.) In general, the preferred thing is to "use" a module - and to create modules instead of libraries if you're building things.

For more info, please see 'perldoc perlmodlib'.


-- 
Human history becomes more and more a race between education and catastrophe. -- HG Wells

In reply to Re: perl file extenson question by oko1
in thread perl file extenson question by perlfan99

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.