perl

How do I read back in the output of Data::Dumper?

Let's say I have a text file created using Data::Dumper, along the lines of: my $x = [ { foo => 'bar', asdf => undef }, 0, -4, [ [] ] ]; I'd like to read that file back in and get $x back. I tried this: my $vars; { undef $/; $vars = <FILE>; } eval $vars; But it didn't seem to work -- $x not only isn't defined, when I try to us...

How do I fix "`as_number' is not a Pari function name" in Math::Pari called by Math::BigInt?

On Perl 5.8.5 I am seeing the error listed in the question. I am running these version modules: Math::BigInt: 1.89 Math::BigInt::FastCalc: 0.19 Math::BigInt::GMP: 1.24 Math::BigInt::Pari: 1.13 Math::BigRat: 0.22 bignum: 0.22 The module producing the error is Math::Pari. This is all in an attempt to get Net::SFTP working to put a f...

Is there a Ruby equivalent to Perl's Data::Rmap?

Perl's Data::Rmap allows you to recursively evaluate a BLOCK over a list of data structures (locally setting $_ to each element) and return the list composed of the results of such evaluations. $_ can be used to modify the elements. This is useful for iterating over things like nested hashes, or hierarchies of arrays of hashes and the l...

What's the best action persistence technique for a Catalyst application?

I'm writing a Catalyst application that's required to have a fairly short session expiration (15 minutes). I'm using the standard Catalyst framework authentication modules, so the user data is stored in the session -- i.e., when your session expires, you get logged out. Many of the uses of this application will require >15 minutes to co...

How can I edit Kerberos 5 configuration files with Perl?

Has anyone come across a Perl module that will parse (and write) kerberos configuration files (ie /etc/krb5.conf)? I have looked at quite a few parsing modules like Config::General, Config::Auto, etc., but none seem to be able to handle nested structures like the following: pam = { debug = false ticket_lifetime = 36000 renew_lifet...

How can I merge PDF files with Perl?

Using Perl, how can I combine or merge the sample PDF files into a single PDF file? ...

How do I copy symbolic links in Perl?

Hi all, How do I copy a symbolic link (and not the file it points to) in a Perl program while preserving all of the symbolic link attributes (such as owner and permissions)? Thanks, splintor ...

How can I substitute regexp matches and map the substitutions in Perl?

I.e.: echo H#97llo | MagicPerlCommand Stdout: Hallo were MagicPerlCommand is something like perl -pnle "s/#(\d+)/chr(\1)/ge" (but that doesn't work). ...

How do I find the case-insensitive unique elements of two arrays in Perl?

I have three arrays. @array1 containing filenames @array2 containing filenames @unique which I want to contain the unique items I use the following code to compare the two arrays and output a third array that contains the unique filenames. @test{@array1} = (); @unqiue = grep {!exists $test{$_}} @array2; However the output is case...

Is there an andand for Perl?

I'd rather do this: say $shop->ShopperDueDate->andand->day_name(); vs. this: say $shop->ShopperDueDate->day_name() if $shop->ShopperDueDate; Any ideas? (This idea is inspired by the Ruby andand extension.) (Actually it is inspired by the Groovy language, but most people don't know that ;-) update: I think that both maybe() and e...

Why can't DynaLoader.pm load SSleay.dll for Net::SSLeay and Crypt::SSLeay?

I have Perl v5.10. I am trying to install Net::SSLeay 1.30 and Crypt::SSLeay 0.57. I have already installed OpenSSL 0.9.8e. For Net::SSLeay 1.30 I followed these steps: perl Makefile.PL -windows C:\openssl nmake nmake test -- test fails nmake install perl test.pl but I got an fatal error as: D:\perl\Net_SSLeay.pm-1.30>perl -w te...

How do I use Perl's Win32::IntAuth to connect via single sign-on?

I have Perl 5.10. How can I connect to the server using the single sign-on method? I have to send a service ticket to the server and save the credentials returned by the server. Is Win32::IntAuth is useful for this? How can I use the Win32::IntAuth module in script? I have installed the Win32::IntAuth module in Perl v5.10. Please sugge...

How can I find the exact amount of physical memory on Windows x86-32bit using Perl or any other language?

I need to know how much physical memory a windows machine has, using Perl. I've tried using Win32::SystemInfo. However this module states the following caveat: On Intel x86 computers with more than 2 GB and less than 4 GB of memory, the MemoryStatus function will always return 2 GB for TotalPhys. Similarly, if the total available me...

How can I filter out specific column from a CSV file in Perl?

I am just a beginner in Perl and need some help in filtering columns using a Perl script. I have about 10 columns separated by comma in a file and I need to keep 5 columns in that file and get rid of every other columns from that file. How do we achieve this? Thanks a lot for anybody's assistance. cheers, Neel ...

What's the simplest way to return the first line of a multi-line string in Perl?

When I say simple, I mean, within an expression, so that I can stick it in as a value in a hash without preparing it first. I'll post my solution but I'm looking for a better one that reminds me less of VB. :) ...

How do I call a C++ static library from Perl?

I'm writing a C++ static library that needs to be shared among several applications, one of them written in Perl. Unfortunately, I only barely know the core Perl language (I read the Llama book), and I'm not all that familiar with its libraries. How do you make calls to an external C++ binary from a Perl script? By Google search, I fo...

What's the best way to parse Excel file in Perl?

What's the simplest way to parse an Excel file in Perl? Converting it to a text file would also work. ...

How can I find memory leaks in long-running Perl program?

Perl uses reference counting for GC, and it's quite easy to make a circular reference by accident. I see that my program seems to be using more and more memory, and it will probably overflow after a few days. Is there any way to debug memory leaks in Perl? Attaching to a program and getting numbers of objects of various types would be a...

What are good references for Perl programmers who want to learn PHP?

I know Perl quite well, but have not worked with PHP. Any books or references that are targeted to people who know Perl and want to start using PHP? ...

What is the difference between new Some::Class and Some::Class->new() in Perl?

Many years ago I remember a fellow programmer counselling this: new Some::Class; # bad! (but why?) Some::Class->new(); # good! Sadly now I cannot remember the/his reason why. :( Both forms will work correctly even if the constructor does not actually exist in the Some::Class module but instead is inherited from a parent somewhere....