aadem has asked for the wisdom of the Perl Monks concerning the following question:

Hello everyone, im coming from a nice background in java, and decided to pick up perl for my text parsing needs as from what i read, its the best. One thing im having a bit of a hard time understanding... What do i save my newly written perl scripts as?

ive seen .pl, and .plx, and have been using .plx as i read .pl was conventionally used for what are called 'perl libraries'

I searched for the answer to this but couldnt find anything. Anyone care to shed some light on the issue for me?

Replies are listed 'Best First'.
Re: new perl user
by GrandFather (Saint) on Mar 10, 2011 at 20:43 UTC

    In the Windows world .pl is, as far as I have seen, pretty much always used for Perl scripts and .pm (for any OS) is used for Perl modules (which contain 'library' code). I strongly recommend you use .pl for your script file extension.

    You may also be interested in Padre as a Perl development environment and of course you should have a look through the Tutorials section too.

    True laziness is hard work
Re: new perl user
by Anonymous Monk on Mar 10, 2011 at 20:54 UTC
    Welcome :) Read perlintro

    plx is a windows throwback, because windows doesn't use shebang but assoc (C:\> help assoc), and before perl5, there were no modules, so libraries were just .pl files, and perl5 includes some (now unsupported) compatibility libraries

    $ perl -e " require 'ctime.pl'; print ctime()" Wed Dec 31 16:00:00 PST 1969
    so activestate (who ported perl to win32, then microsoft sponsored them) wanted to distinguish these libraries (non-executable) from programs (executable), so that if you typed pwd.pl (or clicked on pwd.pl), it opened pwd.pl in notepad (or whatever), but if you typed superfly.plx (or clicked it), it executed perl superfly.plx

    I also think there was a superfly.plw which executed wperl superfly.plw (wperl is GUI version, non-console)

    I don't know if this still survives in activeperl, but I don't think strawberryperl uses it .... you can manage this yourself see C:\> help ftype, it actually shows perl as the example

      Just tested on ActivePerl 5.12 -- it does associate .pl extension to perl, but does not setup anything for .plx.

        Simple. Don't use .plx - it's not conventional. Use .pl for scripts and .pm for modules. In the *nix world drop the .pl (no extension for scripts, but don't forget to use #!/usr/bin/perl as the first line), but carry on using .pm.

        True laziness is hard work
        FWIW, IIRC, .PLX was also adopted as an IIS webserver convention
Re: new perl user
by wind (Priest) on Mar 10, 2011 at 20:32 UTC
    .pl for perl scripts or perl libraries as you said. and .pm for perl modules is the standard convention.