How can I generate call graphs for Perl modules and scripts? - perl

I have a bunch of Perl scripts and Perl modules given to me by someone. I have a driver program that tests all these scripts and modules. I want to generate a call graph and see the flow.
Is there something available for Perl for doing this?
I'd like something like pycallgraph (for python). I am running all this in AIX.

Simon Cozens tells you how to do it in Profiling Perl on Perl.com. He uses a combination of Devel::DProf and GraphViz.

Related

How to get the list of "standard" perl modules available in system?

There is a phrase in perlmodlib(1):
It's possible that not all modules listed below are installed on your
system. For example, the GDBM_File module will not be installed if you
don't have the gdbm library.
How to get actual list of the standard modules installed in the system?
The cpan command can do it:
% cpan -a
I wrote App::Module::Lister to do this job. Although it's a module, it's also a program that does what you want when you run it like a program:
% perl `perldoc -l App::Module::Lister`
Several other Stackoverflow questions answer this for particular modules, including:
How do I check whether a Perl module is installed?
How can I check if I have a Perl module before using it?
How to check availability of Perl, its version and presence of a required module?
For your particular question, though, do you really care what's implementing your DBM features? Do you have some question about that?

How do I create a static library with C or C++ linkage from a Perl module?

I have a very big Perl module, and I am expecting to call it in my Visual C++ project. I know there are tools like perl2exe and pp that can convert Perl modules to standalone executables (abc.exe).
I don't like the standalone executable because it makes the interface very complex. I have to call the Perl module by creating a process and communicating with it using standard input/output.
It will be much easier if the Perl module is a C/C++ static library. Just link it and call a function!
Thanks in advance!
You can't (yet|easily) compile modules. Instead, embed the Perl interpreter as a library.
You can indeed statically link your module into your C project. The thing to realise is that you need to link in perl too. perl is a library heavily used by Perl code (and it would be so even if Perl code could be compiled to machine language).
perlembed documents how to do this.

Is Tinyperl dead?

I'm looking for a light and portable perl release and found this one, but it seems there is no activity since 2003, which could be ok for me but I want to know if there is known issues.
So, if you can provide me some feedbacks, you're wellcome :)
From my experience, the best way to make distributable Perl scripts for Windows systems is to use a packager like PAR::Packer or ActiveState's PerlApp.
Of course this only works if you don't need to do anything on the fly. But it works really well if you have a collection of scripts that you want to move around and use on many systems.
As a replacement for .bat files, as you indicate in your comments, I have found that I can install enough CPAN modules with Strawberry Perl to make more-or-less cross-platform Perl scripts.
See also Is there a portable Perl? which points to the portable version of Strawberry Perl
There is also a Portable Perl from PortableApps
NB: I have used neither one

Is there a Standard or Best Practice for Perl Programs, as opposed to Perl Modules?

I've written any number of perl modules in the past, and more than a few stand-alone perl programs, but I've never released a multi-file perl program into the wild before.
I have a perl program that is almost at the beta stage and is going to be released open source. It requires a number of data files, as well as some external perl modules -- some I've written myself, and some from CPAN -- that I'll have to bundle with it so as to ensure that someone can just download my program and install it without worrying about hunting for obscure modules.
So, it sounds to me like I need to write an installer to copy all the files to standard locations so that a user can easily install everything. The trouble is, I have no idea what the standard practice would be for this. I have found lots of tutorials on perl module standards, but none on perl program standards.
Does anyone have any pointers to standard paths, installation proceedures, etc, for perl programs? This is going to be complicated by the fact that the program is multi-platform. I've been testing it in Linux, but its designed to work equally well in Windows.
Take a look at PAR and PAR::Packer. You can bundle all of your requirements (even non-Perl requirements) into one file. With PAR::Packer, the user doesn't even need to have Perl installed for it to work.
You might also look at how the various App::* distributions are setup.
The standard installers for modules (ExtUtils::MakeMaker, Module::Build, Module::Install) also work the same way for scripts.
Using such a standard Perl tool will help you to:
distribute your application on the
CPAN (and you'll benefit from
automated tests on various platforms
by CPAN Testers), and so your app
will be installable (with all its dependencies) from the CPAN
shell
help packagers of Linux/BSD distributions to make packages for your product

How do I add Perl scripting support to a Delphi application?

PLDelphi is a Perl project hosted on CPAN. I am currently working on a Delphi application and I am investigating the possibility of adding Perl scripting support and read about PLDelphi.
Ideally, I'd like my application to not require Perl to be installed. PLDelphi claims to support this:
To use PLDelphi from your Delphi
application without need to install
Perl you will need this files in the
main diretory of your application:
PLDelphi.dll - The PLDelphi
library that loads the Perl
interpreter. PLDelphi.pm - Perl
side of PLDelphi. Perl56.dll -
The Perl library in case that you have
Perl built dynamic. PLDelphi_dll.pas -
PLDelphi classes and DLL wrapper.
lib/* - A Perl lib directory with basic .pm files (strict, warnings, etc...)
I am aware of RemObjects PascalScript and embedding Python in Delphi, but in this instance, I am interested primarily in Perl support.
Has anyone used PLDelphi with success? Or have you found other ways to execute Perl scripts from Delphi without the full Perl installation available locally?
EDIT:
To be more clear, I found 1 potential solution and that is using PLDelphi. However, I'd like to know if anyone has used it (last updated in 2004) before, and how well it worked.
I'm also interested in hearing about any other options for embedding a Perl interpreter with Delphi.
You could use Windows Script Host (which comes with VBScript and JScript by default) and install PerlScript from ActiveState.
Sadly PLDelphi isn't updated for XE3 or 64 bits there for won't work with Perl 5.16
I was really looking for a solution that didn't require installing anything on the client. It appears that PLDelphi is not working with ActivePerl 5.10...so I don't believe there is a ready solution to embedding Perl within a Delphi application.