Perl: How to load some functions automaticaly, starting Perl inteructively (with -d -e 0)?

I would like to use Perl in 'interactive' mode (kind off), starting it by
> perl -d -e 0;

But I need to have some function be read on loading.
Also, it should not be for anyone who starting Perl or use it any how.
I did try to search, but not much result.
I have try a file '.perldb': seems, perl did try to read that (complained on permission mode), but no defined functions available after that.

By now I only able to load functions by (having all them in .perldb)

   DB<#> do('.perldb');   

command, but it is uncomfortable, starting from different locations...,
and I would like to have the file to be load automaticaly when I starting the perl in debug mode.

I guess, Perl should have such possibility.

I would appreciate your help!

(No any reply on pretty simple question: not many Perl developers?)

Finally, I am using such way:

  • file named as a Perl module: with 'pm' in extension.
  • Starting Perl in 'interactive' mode I use -M<module_name> and -I<dir_name>
  • if I need it in some Perl-script that stared with sheband #!/usr/bin/perl I have on that line additionaly -I<dir_name> and one of starting line:
    USE <module_name>

So, the <module_name> is the file name without the .pm extension, and
-I<dir_name> is including to @INC array the directory of the file, allowing the Perl to search for the module (under USE) in that directory.

And, finaly, to avoid typing for starting Perl interactively, I use alias with those -I<dir> and -M<mdl>

1 Like