Get a list of all pragmas

T

tuser

I am running perl 5.8.7 under Ubuntu Linux 6.06 LTS.

Looking at "perldoc perltoc", I can see the list of pragmas in my
version of perl.

Then I tried to get the list of all pragmas from a perl program:
=================
use ExtUtils::Installed;
$, = "\n";
print ExtUtils::Installed->new()->modules(), "";
=================

but that did only give me the manually installed modules from CPAN, not
even the pre-installed standard modules, let alone the pragmas !

How can I get this list of pragmas programmatically from within a perl
program (other than scanning the "perldoc perltoc" output) ?
 
A

anno4000

tuser said:
I am running perl 5.8.7 under Ubuntu Linux 6.06 LTS.

Looking at "perldoc perltoc", I can see the list of pragmas in my
version of perl.

Then I tried to get the list of all pragmas from a perl program:
=================
use ExtUtils::Installed;
$, = "\n";
print ExtUtils::Installed->new()->modules(), "";
=================

but that did only give me the manually installed modules from CPAN, not
even the pre-installed standard modules, let alone the pragmas !

How can I get this list of pragmas programmatically from within a perl
program (other than scanning the "perldoc perltoc" output) ?

This may get you started. It finds all all-lower-case module names
in @INC. Some are probably not meant for public consumption.

use File::Find;
my @prag;
find sub { /^([[:lower:]]+).pl$/ and push @prag, $1 }, @INC;
print join "\n", @prag, '';

Anno
 
H

himanshu.garg

tuser said:
I am running perl 5.8.7 under Ubuntu Linux 6.06 LTS.

Looking at "perldoc perltoc", I can see the list of pragmas in my
version of perl.

Then I tried to get the list of all pragmas from a perl program:
=================
use ExtUtils::Installed;
$, = "\n";
print ExtUtils::Installed->new()->modules(), "";
=================

but that did only give me the manually installed modules from CPAN, not
even the pre-installed standard modules, let alone the pragmas !

How can I get this list of pragmas programmatically from within a perl
program (other than scanning the "perldoc perltoc" output) ?

You could try Module::CoreList module available from CPAN for this.

See Also:-
perldoc -q installed

Thank You,
++imanshu.
 
T

tuser

tuser said:
I am running perl 5.8.7 under Ubuntu Linux 6.06 LTS.

Looking at "perldoc perltoc", I can see the list of pragmas in my
version of perl.

Then I tried to get the list of all pragmas from a perl program:
=================
use ExtUtils::Installed;
$, = "\n";
print ExtUtils::Installed->new()->modules(), "";
=================

but that did only give me the manually installed modules from CPAN, not
even the pre-installed standard modules, let alone the pragmas !

How can I get this list of pragmas programmatically from within a perl
program (other than scanning the "perldoc perltoc" output) ?

This may get you started. It finds all all-lower-case module names
in @INC. Some are probably not meant for public consumption.

use File::Find;
my @prag;
find sub { /^([[:lower:]]+).pl$/ and push @prag, $1 }, @INC;
print join "\n", @prag, '';

Anno

Cool ! - that works brilliantly.

I did not think of pragmas being all-lowercase modules, but yes, they
are ! -- perl has been (and probably will be) surprising me again and
again.

Thanks.
 
T

tuser

You could try Module::CoreList module available from CPAN for this.

See Also:-
perldoc -q installed

Thanks, Module::CoreList will serve me as a test to see whether all
modules that should be available are installed on my system.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top