perl-module

Custom missing module message

浪子不回头ぞ 提交于 2019-12-02 09:19:35
问题 I would like to be able to output a custom error message to STDERR if one of my modules cannot be found. From what I understand if I import the module with the use command the lack of the module will be discovered prior to my script being executed which poses a significant problem to achieving the result that I am looking for. Basically what I am looking for is a Perl equivalent of catching the ImportError exception in Python. 回答1: To catch an exception in Perl you should use the eval

Installing Older Version of Module in Active Perl

旧城冷巷雨未停 提交于 2019-12-02 08:28:52
I am trying to install the Date::Manip Module in Perl. I am running Perl Version 5.14.2 and it does not seem to be installing successfully through the PPM. (PPM throws a 401 Access required error). I am guessing that the error here is that the Version of Perl is outdated for the module in the ppm. Since this is in the server and there are many other scripts running on a day to day basis, I can not upgrade the Perl version. I need to install the previous version of the Date::Manip module but this is not found in the ppm. How do I go about doing this ? Thanks ! The reason the 401 error occurs is

Attempting to inline Java into Perl via the Inline::Java module

前提是你 提交于 2019-12-02 07:45:33
问题 This is my first attempt to inline Java code in Perl. We cannot use the standard SFTP command on our system. This is out of my power. We have a jarfile called SFTP.jar which can be used. The previous person before me was able to get Inline::Perl to work, but his implementation was sloppy, and I'd like to clean it up. I am working on a Windows system on the H:\svn directory. I have my module under the H:\svn\FMS3 directory, and I have a jarfile called SFTP.jar under the H:\svn\FMS3\Sftp.pm

Keep getting error “Can't locate Image/Grab.pm in @INC” after installing the Perl mod

↘锁芯ラ 提交于 2019-12-02 07:45:13
问题 I'm a bit new to programming and I'm having some trouble writing a Perl script that will grab all the images from a webpage and save them in a specified directory. Here's my code: use warnings; use strict; use lib '/home/User1/strawberry/cpan/build'; use Image::Grab; $pic = Image::Grab->new(SEARCH_URL=>'http://www.examplesite.com', REGEXP =>'.*\.gif|.*\.jpg'); my $dir = 'images'; opendir (IMG, ">>$dir") || die "Directory doesn't exist - $!\n"; foreach ($pic) { print IMG "$_\n"; } closedir IMG

how to import multiple custom modules in our own perl script?

可紊 提交于 2019-12-02 06:50:15
问题 I have say 100 custom packages like (file1.pm, file2.pm, file3.pm, file4.pm, file5.pm, file6.pm ) Each file contains one function. i want to import all in my every simple perl script. How to import them in easy way. Please suggest any easiest way? 回答1: You can use this small script to load all 100 modules into it: # pragma use strict; use warnings; # standard modules needed by the script use Module::Load; # the loop below loads all 100 of your custom modules (file1.pm, file2.pm, ...) foreach

Keep getting error “Can't locate Image/Grab.pm in @INC” after installing the Perl mod

。_饼干妹妹 提交于 2019-12-02 06:05:49
I'm a bit new to programming and I'm having some trouble writing a Perl script that will grab all the images from a webpage and save them in a specified directory. Here's my code: use warnings; use strict; use lib '/home/User1/strawberry/cpan/build'; use Image::Grab; $pic = Image::Grab->new(SEARCH_URL=>'http://www.examplesite.com', REGEXP =>'.*\.gif|.*\.jpg'); my $dir = 'images'; opendir (IMG, ">>$dir") || die "Directory doesn't exist - $!\n"; foreach ($pic) { print IMG "$_\n"; } closedir IMG; This is the error I get when I run the script in PuTTY: Can't locate Image/Grab.pm in @INC (@INC

how to import multiple custom modules in our own perl script?

≡放荡痞女 提交于 2019-12-02 05:12:40
I have say 100 custom packages like (file1.pm, file2.pm, file3.pm, file4.pm, file5.pm, file6.pm ) Each file contains one function. i want to import all in my every simple perl script. How to import them in easy way. Please suggest any easiest way? You can use this small script to load all 100 modules into it: # pragma use strict; use warnings; # standard modules needed by the script use Module::Load; # the loop below loads all 100 of your custom modules (file1.pm, file2.pm, ...) foreach my $i (1 .. 100) { load "file$i"; } As I said in a comment, I think this is a terrible way to organise your

RTF to TEXT conversion using perl

 ̄綄美尐妖づ 提交于 2019-12-02 04:24:46
Can somebody tell me how can we convert the rtf file into text with all the tags, tables and formatted data using perl programming language ? @Ahmad Bilal , @petersergeant : I have been using the below code for RTF to TXT conversion and i am able to convert into text. But the problem is i am unable to capture table or image formats and even all the entities in the inputfile are not captured using the program. use 5.8.0; use strict; use warnings; use Getopt::Long; use Pod::Usage; use RTF::HTMLConverter; #------------------------------------------------------------------- #Variable Declarions #-

Dynamically loading Perl modules

陌路散爱 提交于 2019-12-01 21:55:53
I am trying to make an extensible system whereby I can code up a new module to be a handler. I want the program to automatically load any new .pm file that is put into the Handlers directory and conforms to a Moose::Role interface. I'm wondering whether there is a Perl module or a more Moose sanctioned way to do this automatically? Here is what I have built so far, but it seems a little verbose and there has got to be a simpler way to do it. handler.pl contains: #!/usr/bin/perl use Handler; use Data::Dumper; my $base_handler = Handler->new(); $base_handler->load_modules('SysG/Handler'); print

Undefined subroutine &PDL::divide

[亡魂溺海] 提交于 2019-12-01 21:01:20
I'm trying Perl's PDL in the following code: #!/usr/bin/perl -w use strict; use PDL::Core qw(pdl); use PDL::Math qw(isfinite); use PDL::Primitive qw(statsover); my $div = 4; my @array1 = (0..10); my $pdl_array = log(pdl(@array1)/$div); $pdl_array->where(!isfinite($pdl_array)) .= 0; my($mean,$stdev) = statsover($pdl_array); die $pdl_array,"\n",$mean," ",$stdev,"\n"; and I'm getting this error: Undefined subroutine &PDL::divide called at ./compare_const.pl line 10. Any hint, please?Thanks a lot. PDL is unusual in its design, and therefore has an unusual and somewhat fragile import mechanism.