in reply to Re: Writing my first module
in thread Writing my first module

Wow, thank you so much for answering all my questions so quickly and in such great detail!!!

I have one more question. I guess, I can look this up myself. My assumption is if the shebang is not mandatory for pm files in Linux (because pm files are not meant to be executed from command line), then I guess the file's permissions can be 644. They are not required to be 755. Correct?

Replies are listed 'Best First'.
Re^3: Writing my first module
by haukex (Archbishop) on Aug 30, 2023 at 10:53 UTC
    My assumption is if the shebang is not mandatory for pm files in Linux (because pm files are not meant to be executed from command line), then I guess the file's permissions can be 644. They are not required to be 755. Correct?

    Yes!

Re^3: Writing my first module
by eyepopslikeamosquito (Archbishop) on Aug 30, 2023 at 11:06 UTC

    My assumption is if the shebang is not mandatory for pm files in Linux (because pm files are not meant to be executed from command line), then I guess the file's permissions can be 644. They are not required to be 755.

    Yes. For cheap thrills, I ran these commands on my recently installed perl 5.38 on Ubuntu:

    ~/localperl$ find . -name '*.pm' -ls >pm.tmp ~/localperl$ find . -name '*.pl' -ls >pl.tmp

    All the .pm files have permissions like this:

    -r--r--r-- ... ./lib/5.38.0/Carp.pm

    The perl commands in the bin directory designed to be run as commands have permissions like this example of the prove command:

    -rwxr-xr-x ... prove

    These text files also tend to start with a shebang line like:

    #!/home/youruser/localperl/bin/perl

    There are also plenty of .pl files lying around with permissions like this:

    -r--r--r-- ... somefile.pl
    which is fine because you can still run them manually via:
    perl /somepath/somefile.pl

Re^3: Writing my first module
by Marshall (Canon) on Aug 30, 2023 at 13:17 UTC
    I came back - my back is hurting and couldn't sleep....

    There is one trick that I sometimes use....
    It is possible for your module to know if it was "used" versus executed directly. This allows me to put a test driver in the module itself that I use during development that presents more info that just a "pass/fail". If you do this, you will want your .pm to be an executable file under Unix.

    #Normal module preamble here... sub test{ print "this is a dev test...\n"; } test() if not caller; ### Run test() if run directly #Normal rest of module code here.... 1;
      Oh, what a nice trick! That's so cool!! :-)