perl

GVIM and multiple programming languages

My day job involves coding with Perl. At home I play around with Python and Erlang. For Perl I want to indent my code with two spaces. Where as for Python the standard is 4. Also I have some key bindings to open function declarations which I would like to use with all programming languages. How can this be achieved in GVIM? As in, is the...

Is there a Perl statistics package that doesn't make me load the entire dataset at once?

I'm looking for a statistics package for Perl (CPAN is fine) that allows me to add data incrementally instead of having to pass in an entire array of data. Just the mean, median, stddev, max, and min is necessary, nothing too complicated. The reason for this is because my dataset is entirely too large to fit into memory. The data sourc...

How can I use an array as a hash value in Perl?

Ok, so here's the entire structure I'm trying to create. I need to create an anonymous array that I can use as a hash value. This works in my program: $result = { count, 2, elementList, [ {name => "John Doe", age => 23}, {name => "Jane Doe", age => 24} ] }; I'm trying to create the exact same thing with cod...

How do I enable PerlCritic support in Komodo IDE 5.1 on Windows?

I'm trying to enable PerlCritic support in Komodo. The official word from ActiveState, the makers of Komodo IDE 5.1 (Win 32) is: "To enable PerlCritic support, please install the 'Perl-Critic' and 'criticism' modules." Well, installing Perl-Critic was a piece of cake: ppm install Bundle-Perl-Critic However, I've search every reposi...

How can I use Perl to start a remote process and not wait for it to finish?

I am running multiple batch files in remote machine using a Perl script residing in the local machine and I want to run this batch files for a long duration. The problem is, the Perl program which is running in the local machine is halting and executing the later commands only after the batch files ends. I want to run batch files in re...

Perl YAML::Syck encoded string, howto properly decode in Java using JYaml?

Using beanstalkd and putting a job in tube/queue that contains a hash that is YAML::Syck encoded (with $YAML::Syck::ImplicitTyping = 1). I need some syntax help on the Java end, as to how to decode handle that string pulled from the beanstalkd job. The Perl hash ends up being encoded as a YAML string that looks like this: --- NameFir...

How can I extract HTML content efficiently with Perl?

I am writing a crawler in Perl, which has to extract contents of web pages that reside on the same server. I am currently using the HTML::Extract module to do the job, but I found the module a bit slow, so I looked into its source code and found out it does not use any connection cache for LWP::UserAgent. My last resort is to grab HTML...

How can I improve Moose performance in non-persistent CGI processes?

Moose is a fantastic object framework. The trouble is that, taken together with its dependencies, it's very big. Our profiling indicates that on our platform, simply loading Moose will incur a 5-6 second overhead on non-persistent CGI application scripts. That's just not acceptable for these one-off applications. By contrast, when we...

What character replacements should be performed to make base 64 encoding URL safe?

In looking at URL safe base 64 encoding, I've found it to be a very non-standard thing. Despite the copious number of built in functions that PHP has, there isn't one for URL safe base 64 encoding. On the manual page for [base64_encode()][1], most of the comments suggest using that function, wrapped with strtr(): function base64_url_e...

How can I split a string into only two parts with Perl?

I have a string that with several parts separated by tabs: Hello\t2009-08-08\t1\t2009-08-09\t5\t2009-08-11\t15 I want to split it up only on the first tab, so that "Hello" ends up in $k and and rest ends up in $v. This doesn't quite work: my ($k, $v) = split(/\t/, $string); How can I do that? ...

How can I get the average and standard deviations grouped by key?

I've need to find the average and standard deviation of a large amount of data in this format. I tried using Excel but there doesn't appear to be an easy way to transpose the columns. What am I missing in Excel or should I just use Perl? Input file format is: 0 123 0 234 0 456 1 657 1 234 1 543 Want result to group the...

How can I test Perl applications using a changing system time?

I have a web application that I want to run some system tests on, and in order to do that I'm going to need to move the system time around. The application used DateTime all the way through. Has anyone got any recommendations for how to change the time that DateTime->now reports? The only thing that comes to mind is subclassing DateTi...

Perl Ora2Pg on Ubuntu

I just tried Ora2Pg on my Ubuntu Jaunty Jackalope. First of all, the installation was hard, but after downloading a few debs & rpms here & there, I was finally managed to install ora2pg via synaptic. However, when I try to run this command ora2pg /tmp/ora2pg.conf I am getting a install_driver(Oracle) failed: Can't load '/usr/l...

What does "vaguely deprecated" mean regarding ?PATTERN?

In the discussion of ?PATTERN?, perlop states "This usage is vaguely deprecated". Does this mean that the ?? matching operator itself will be removed from perl, or does it mean that its semantics will change? Is using ?? a bad idea, or can that warning in perlop be ignored? ...

In Moose, how do I modify an attribute any time it is set?

If you have an attribute that needs to be modified any time it is set, is there a slick way of doing this short of writing the accessor yourself and mucking around directly with the content of $self, as done in this example? package Foo; use Moose; has 'bar' => ( isa => 'Str', reader => 'get_bar', ); sub set_bar { my ($sel...

How can I distribute my Perl application as a single file?

I have a Perl script (foo.pl) that loads Foo.pm from the same directory using the require mechanism: require "./Foo.pm"; ... my $foo = new Foo::Bar; The Foo.pm adheres to the standard module format: package Foo::Bar; ... 1; Rather than distributing my application as two files (foo.pl and Foo.pm) I'd like to distribute only one file...

Why can't my Catalyst application read my Template Toolkit files?

I am trying to get the Catalyst framework to work using Template Toolkit, and I'm having issues with Template::Provider. I've isolated the issue to calls to stat. In Template::Provider::_init, calls to stat work correctly, however in other functions calls to stat return []. It seems like Template::Provider is doing some weird caching stu...

How can I use Perl to test C programs?

I'm looking for some tutorials showing how I could test C programs by writing Perl programs to automate testing. Basically I want to learn automation testing with Perl programs. Can anyone kindly share such tutorials or any experiences of yours which can help me kick-start this process? ...

How can I read the headers from a WinNT portable executable file using Perl?

Hey Folks, I want to work with PE files in Perl and didn't find a module, so I think I will write my own (already did that in delphi once). I only got one problem, when mapping the executable to a buffer, how can i search for octals like 0x00004550 (IMAGE_NT_SIGNATURE), convert them back to writeable strings etc? ...

Are Python list comprehensions the same thing as map/grep in Perl?

I was having some trouble grokking the list comprehension syntax in Python, so I started thinking about how to achieve the same thing in Perl, which I'm more familiar with. I realized that the basic examples (taken from this page) can all be done in Perl with map or grep. E.g. (python) (perl) ...