perl-module

How to view the code block genereated by n or p switch in perl one liner

自闭症网瘾萝莉.ら 提交于 2019-11-28 01:46:57
问题 I am sure I have run this before but for the life of me cant find any reference in perlrun or through Google. Hopefully some of the perl boffins here will be able to answer it. When running a perl one liner with the -ne switch. Is there an option to have the code, that perl will compile, to be outputted to the console? So if I run: crontab -l | perl -ne 'print if /^00/' Then Perl will compile this to: while(<>){ print if /^00/; } I am sure there is a way to have perl spit out the code its

How do I use beta Perl modules from beta Perl scripts?

两盒软妹~` 提交于 2019-11-28 01:01:22
问题 If my Perl code has a production code location and "beta" code location (e.g. production Perl code us in /usr/code/scripts , BETA Perl code is in /usr/code/beta/scripts ; production Perl libraries are in /usr/code/lib/perl and BETA versions of those libraries are in /usr/code/beta/lib/perl , is there an easy way for me to achieve such a setup? The exact requirements are: The code must be THE SAME in production and BETA location. To clarify, to promote any code (library or script) from BETA to

Which Perl module would you recommend for JSON manipulation?

半世苍凉 提交于 2019-11-28 00:52:18
As usual, I'm happy to deal with CPAN because it got all we need. As usual, I'm lost because there is plenty of stuff. I can find the core JSON one by myself, and feel enthusiastic by a JSON::Tiny other. My needs are very simple (parsing stuffs from the Open Library API ) and, maybe someday, expose our own data. Is there any other modules that you like for this task? Miguel Prz JSON module works like a champ, but if you need a faster parser, use this one: JSON::XS , which requires a native compilation. Note that JSON version 2.0 and above is merely a front end for JSON::XS (if installed) or

Installing modules using Strawberry Perl

故事扮演 提交于 2019-11-27 17:29:42
Until now I used ActiveState 's ActivePerl , and used the ppm for installing modules. Last week I moved to Strawberry Perl , but I don't know how I should install modules using Strawberry Perl. What is some information on how module installation is done using Strawberry Perl or is there some link on how to install new modules? Alexandr Ciornii You can still use ppm , but it is not recommended. Run CPAN client from the Strawberry Perl or Strawberry Perl (64-bit) , sub folder Tools , entry in the Start menu. Type install Module::Name there. As Alexandr says, you can use the CPAN client via the

How to check availability of Perl, its version and presence of a required module?

主宰稳场 提交于 2019-11-27 14:51:01
I have written a Perl script, I just want to give it to every one, for that I planned to write a bash script which is used to test the environment of a user and find whether that environment is capable of running the Perl script. I want to test the things like: Whether Perl has installed in that system Perl should have the version 5 or more Whether the module JSON::Any is available Any suggestion would greatly appreciated :-) if perl -MJSON::Any -e 'print "$JSON::Any::VERSION\n"' >/dev/null 2>&1 then : OK else echo "Cannot find a perl with JSON::Any installed" 1>&2 exit 1 fi I often use ' $

What's the best way to discover all subroutines a Perl module has?

和自甴很熟 提交于 2019-11-27 11:37:31
问题 What's the best way to programatically discover all of the subroutines a perl module has? This could be a module, a class (no @EXPORT), or anything in-between. Edit: All of the methods below look like they will work. I'd probably use the Class::Sniff or Class::Inspector in production. However, Leon's answer is marked as 'accepted' since it answers the question as posed, even though no strict 'refs' has to be used. :-) Class::Sniff may be a good choice as it progresses; it looks like a lot of

Which framework should I use to write modules? [closed]

余生长醉 提交于 2019-11-27 10:57:59
What's the best framework for writing modules -- ExtUtils::MakeMaker (h2xs) or Module::Build ? Schwern NOTE This advice is out of date. Module::Build has been removed from the Perl core but lives on as a CPAN module. The pros and cons still stand, and my opinions about MakeMaker still stand. As the former maintainer of ExtUtils::MakeMaker, I like to recommend Module::Build because MakeMaker is a horror show. Module::Build is so much better put together. But those aren't your concerns and I'll present my "least hassle for you" answer. Executive Summary: Because Module::Build support is not 100%

How does a Perl program know where to find the file containing Perl module it uses?

折月煮酒 提交于 2019-11-27 08:25:29
If my Perl program uses Perl modules, how will it determine where to find the file containing the module code? For example, if the program contains: use MyModule1; # Example 1 use This::Here::MyModule2; # Example 2 where will it look? DVK Perl interpreter (which runs your perl program) will use a special array called @INC to search for a file containing the module. Each value in the @INC array is a directory name ( but see note below ); Perl will search within those directories in a loop using the rules specified below. (Please refer to this SO post for details of how the contents of @INC are

How can I check if a Perl module is installed on my system from the command line?

点点圈 提交于 2019-11-27 05:11:11
问题 I tried to check if XML::Simple is installed in my system or not. perl -e 'while (<@INC>) { while (<$_/*.pm>) { print "$_\n"; } }' The above one-liner was used for listing all modules installed in my system. However, it is not listing XML modules. However, the following executes fine. perl -e "use XML::Simple " What might be the issue? 回答1: You can check for a module's installation path by: perldoc -l XML::Simple The problem with your one-liner is that, it is not recursively traversing

In Perl, what is the difference between a .pm (Perl module) and .pl (Perl script) file?

别来无恙 提交于 2019-11-26 23:58:57
问题 What is the Difference between .pm (Perl module) and .pl (Perl script) file? Please also tell me why we return 1 from file. If return 2 or anything else, it's not generating any error, so why do we return 1 from Perl module? 回答1: At the very core, the file extension you use makes no difference as to how perl interprets those files. However, putting modules in .pm files following a certain directory structure that follows the package name provides a convenience. So, if you have a module