perl-module

export vs export_ok in perl

こ雲淡風輕ζ 提交于 2019-11-30 04:50:17
I can not understand what is the difference/use case of EXPORT_OK vs EXPORT . Most resources mentions something in the lines of: @Export allows to export the functions and variables of modules to user’s namespace using the standard import method. This way, we don’t need to create the objects for the modules to access its members. @EXPORT_OK does export of symbols on demand basis for selective list of symbols (subroutines and variables) of the module. But I really don't see the difference/meaning here. Can someone please provide a small fundamental example of the difference/usage of these 2

Perl - Package/Module Issues

非 Y 不嫁゛ 提交于 2019-11-30 04:41:09
问题 From everything I've read on using Perl modules, the basic usage is: Module file with .pm extension, which includes the statement package <name> , where <name> is the filename of the module without the extension. Code file that uses module contains the statement use <name>; . The application I'm coding has one main code script which uses about 5 modules. I had forgotten to include the package <name> statement in the modules, but my code still ran just fine with the use <name> statement. I

Perl Install PAR:Packer Problems

对着背影说爱祢 提交于 2019-11-29 14:45:32
问题 My perl version is 5.16.2 on my Windows 7 64bit, I failed to install PAR:Packer. I tried active perl and strawberry perl , both got the same error. Can you please give me some suggestion. Below is my experience: I tried ppm install PAR:Packer , version 1.013, But when I use pp, I got the error: Perl lib version (5.16.2) doesn't match executable version (v5.16.0). I also tried cpan install PAR:Packer , version 1.014. But I got the error during installation. The pop up window says: par.exe has

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

非 Y 不嫁゛ 提交于 2019-11-29 08:08:58
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 going to use including any begin or end blocks. hopefully someone knows how. You may be thinking of the B:

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

旧城冷巷雨未停 提交于 2019-11-29 07:38:43
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 production, the ONLY thing which needs to happen is literally issuing cp command from BETA to prod

export vs export_ok in perl

六眼飞鱼酱① 提交于 2019-11-29 01:45:52
问题 I can not understand what is the difference/use case of EXPORT_OK vs EXPORT . Most resources mentions something in the lines of: @Export allows to export the functions and variables of modules to user’s namespace using the standard import method. This way, we don’t need to create the objects for the modules to access its members. @EXPORT_OK does export of symbols on demand basis for selective list of symbols (subroutines and variables) of the module. But I really don't see the difference

What does “1;” mean in Perl?

烂漫一生 提交于 2019-11-28 20:54:35
问题 I have come across a few Perl modules that for example look similar to the following code: package MyPackage; use strict; use warnings; use constant PERL510 => ( $] >= 5.0100 ); require Exporter; our @ISA = qw(Exporter); our @EXPORT = qw( ); { #What is the significance of this curly brace? my $somevar; sub Somesub { #Some code here } } 1; What is the significance of 1; and of the curly braces that enclose the $somevar and the Sub? 回答1: 1 at the end of a module means that the module returns

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

自闭症网瘾萝莉.ら 提交于 2019-11-28 18:42:19
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 thought has gone into it. sub list_module { my $module = shift; no strict 'refs'; return grep { defined

How to add header, footer with images using PDF::API2::Lite?

随声附和 提交于 2019-11-28 04:16:24
问题 Is it possible to add header(with text and one image) and footer (with page number) with images. I wrote below code to create a PDF document which shows png images. If this can be done easily with any other module, please suggest.Really appreciate response with sample code. use strict; use PDF::API2::Lite; use Getopt::Long; my $outfile; my $path; my $options = GetOptions( "outfile=s" => \$outfile, "images=s" => \$path,); my @images = sort glob("$path") or die "No Files\n"; my $pdf = PDF::API2

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

女生的网名这么多〃 提交于 2019-11-28 03:14:09
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? 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 Example::Plot::FourD and you put it in a directory Example/Plot/FourD.pm in a path in your @INC , then use and