perl

How do I configure apache2 to run Perl CGI scripts?

Hello, Im would like to configure apache2 running on Kubuntu to execute Perl CGI scripts. I've tried some steps I came across by googling, but nothing seems to work. Can someone please point me to the right way of achieving this? Thank You. ...

Out of memory error while parsing a specific excel file from a Perl Program

When the perl code is run the program generates some warnings and terminates. The output is as below: D:\Perl\bin\search tool>perl testa.pl UTF-16 surrogate 0xdb79 at D:/Perl/site/lib/Spreadsheet/ParseExcel/FmtDefault.pm line 81. UTF-16 surrogate 0xdbb1 at D:/Perl/site/lib/Spreadsheet/ParseExcel/FmtDefault.pm line 81. UTF-16 surrogat...

Why does Moose's builder take a string value?

Moose::Manual::Attributes states: As an alternative to using a subroutine reference [for default], you can instead supply a builder method for your attribute: ... This has several advantages. First, it moves a chunk of code to its own named method, which improves readability and code organization. So, your attribute could defin...

Does plperlu reload Perl modules if they change?

If I wrote something in plperlu, and it used a Perl module (e.g. MyModule::Foo), when would that module be reloaded? Does it keep track of them like mod_perl's Apache2::Reload, so that a touch will cause a reinterpretation? ...

Is %$var dereferencing a Perl hash?

I'm sending a subroutine a hash, and fetching it with my($arg_ref) = @_; But what exactly is %$arg_ref? Is %$ dereferencing the hash? ...

How do I find out the filename of a Perl package?

I would like to translate a Perl package name to the full path of the file. say package_name_to_path('Foo::Bar::Baz'); /tmp/Foo/Bar/Baz.pm I know there is a CPAN module to do this? I just can't find it again? ...

How can I encrypt a message in Perl to decrypt it in C#?

Hi all, I am needing to encrypt using Perl and decrypt on .Net (C#). i.e. Perl encrypts a file and my .Net code decrypts the file (and even maybe validates integrity). The problem is that I am not familiar with the encryption capabilities of Perl. Can anyone offer guidance on how best to approach this and what the possibilities are? T...

How can I autofold POD in Perl with vim?

I'm trying to edit files with vim and get the POD automatically folded (just the POD, not the Perl). I can't get it to work, so I've tried disabling all of my plugins and my .vimrc with this: vim -u NONE some_perl.pl I assume that my POD blocks in my project with start with '=head1', '=head2' or '=head3'. They will always end with '...

How can I anonymise XML data for selected tags?

My question is as follows: I have to read a big XML file, 50 MB; and anonymise some tags/fields that relate to private issues, like name surname address, email, phone number, etc... I know exactly which tags in XML are to be anonymised. s|<a>alpha</a>|MD5ed(alpha)|e; s|<h>beta</h>|MD5ed(beta)|e; where alpha and beta refer to any c...

How can I tail a remote file?

I am trying to find a good way to tail a file on a remote host. This is on an internal network of Linux machines. The requirements are: Must be well behaved (no extra process laying around, or continuing output) Cannot require someone's pet Perl module. Can be invoked through Perl. If possible, doesn't require a custom built script o...

Why does grep on my array slice cause a stack overflow in Perl?

The other day, needed to iterate over a subset of an array at a time. Initially, I did this with splice - tearing apart the array was no problem in this case. It would return N elements at a time, or whatever was left at the end of the list. All went well. Then it turned out I needed the array later. Instead of splice, I switched to...

How do I escape a left paren in a Perl regex?

If I have a file containing some escaped parens, how can I replace all instances with an unescaped paren using Perl? i.e. turn this: .... foo\(bar .... into this .... foo(bar .... I tried the following but receivied this error message: perl -pe "s/\\\(/\(/g" ./file Unmatched ( in regex; marked by <-- HERE in m/\\( <-- HERE / at ...

How can I get the command-line output of a DOS tool using Perl?

Hi, I want to meassure the throughput of a link using Windows build-in FTP tool inside a Perl script. Therefore the script creates the following command script: open <ip> <username> <password> hash get 500k.txt quit Afterwards I run the command script using the following Perl code: system(@args); @args = ("ftp", "-s:c:\\ftp_dl.txt")...

How can I suppress Excel's password prompt in Perl?

Please tell me a solution to suppress passsword prompting of an excel file. use Win32::OLE; my $xlApp = Win32::OLE->new('Excel.Application'); $xlApp->{Visible} = 0; $xlApp->{DisplayAlerts} = 0; # Open excel file. my $xlBook = $xlApp->Workbooks->Open("C:\\Documents and Settings\\username\\Desktop\\te...

Can a PHP script unserialize a Storable file created with Perl?

Can a PHP script unserialize a Storable file created with Perl? ...

How do I read two items at a time in a Perl foreach loop?

What I'm looking for is something like: @list = qw(1 2 3 4 5 6) foreach (@list) { #perl magic goes here print "i: $i, j:$j\n"; } returns: i:1, j:2 i:3, j:4 i:5, j:6 In response to a very good suggestion below, I need to specify that this script will run on someone else's build server, and I'm not allowed to use any modules from...

Why can't C# decrypt the output from Perl's Crypt::Rijndael?

A file has been encrypted by Perl. Initial decrypt attempts failed and I am now trying to ascertain whether there is any hoojoo going on (some other settings required) Duff Perl Code: use strict; use Crypt::Rijndael; my $key ='...'; my $rcipher = Crypt::Rijndael->new ($key, Crypt::Rijndael::MODE_CBC()); undef $/; my $encrypted = <>...

Why does my DBI program complain about 'Undefined subroutine &DBD::Pg::db::_login'?

Hi, I am trying to use PostgreSQL database for storing Apache's session information, but I can't get it to work. It is failing with the following error: Undefined subroutine &DBD::Pg::db::_login It seems that MySQL users have run into the same problem in DBD::MySQL::db. I have the latest CPAN version of both DBI and DBD::Pg. It does...

Can I use perl's switches with /bin/env in the shebang line?

I want to run perl -w using env. That works fine on the command line: $ /bin/env perl -we 'print "Hello, world!\n"' Hello, world! But it doesn't work on the shebang line in a script: #!/bin/env perl -w print "Hello, world!\n"; Here is the error: /bin/env: perl -w: No such file or directory Apparently env doesn't understand the -...

Concise foreach expression in one line

In Perl, one can often avoid using control blocks, like this: print "$_\n" foreach(@files); instead of: foreach(@files){ print "$_\n"; } How does this syntax work in the following, more complex case: die("Not a file: $_") unless -f $_ foreach(@files); It gives me a syntax error. I'm not trying to write obfuscated code, it's ju...