perl

How can I use dispatch tables in Perl?

Possible Duplicate: How do I implement dispatch tables in Perl? I have a hash table that contains commands such as int(rand()) etc. How do I execute those commands? ...

Perl: Can I store backreferences (not their values) in variables?

I'd like to do something like this: my $text = "The owls are not what they seem."; my $pattern = '(\s+)'; my $replacement = '-$1-'; $text =~ s/$pattern/$replacement/g; $text should then be: The- -owls- -are- -not- -what- -they- -seem. But of course it's more like: The-$1-owls-$1-are-$1-not-$1-what-$1-they-$1-seem. I tried all ...

socket pairs, perl, KEEPALIVE, and polling

I've starting using socketpairs on linux and windows in order to capture the output of subprocesses on both platforms. I do this by copying STD* onto one of the sockets in the socketpair (I'm using Win32::SocketPair in perl for socketpair's on windows). The main reason I am doing this is so that read do NOT block on the output file han...

where to play with python and perl?

I want to learn Python and Perl, buy I don't know where need I use it. I can use PHP to build a website or use Java/.Net to build server-side applications or use JavaScript to write dynamic web pages. Where can I use Python and Perl? ...

How can I pipe input into a Java command from Perl?

I need to run a string through a Java program and then retrieve the output. The Java program accepts the string through standard input. The following works: my $output = `echo $string | java -jar java_program.jar`; There is one problem: $string could be just about anything. Any thoughts on a good solution to this problem? ...

Where can I find documentation for Net::Libnet?

Could someone provide some links to additional documentation or tutorials for the CPAN module Net::Libnet? ...

Can actual Perl Regular Expressions be implemented in Java via existing library?

Is there an existing robust Java library which implements a fairly substantial subset of Perl regular expression syntax? Background: I wish to implement a file renamer where renaming is done using Perl regular expressions. The trick is that the project containing said renamer as a component is, currently, 100% in Java in Windows. NOT...

How can I compare the performance of PHP to Perl?

Although both are interpreted languages there are differences or? What are the performance differences of both languages? Even if Perl would be faster than PHP, the most would choose PHP, because of the simplicity of PHP. Does someone have experience in this regard? ...

Passing arbitrary number of parameters to an Oracle function in perl

Take an existing piece of perl code which calls an Oracle function with two params; my $func = $dbh->prepare (q { BEGIN :result := myStoredProc(value1 => :Param1, value2 => :Param2); END; } ); $func->bind_param(":Param1", $opt_a); $func->bind_param(":Param2", $opt_b); $func->bind_param_inout(":result", \$re...

String Matching for /* and */

Hello. I have a text file including the lines below: /* MY TXT File LINE */ /* MY TXT File LINE MORE */ constant private FileName = <A "C:\\TMP\\ALARM.TXT"> constant ConfigAlarms = <U1 0> /* Comment Here*/ I don't know how to divide the comment lines (/* something */): LINE1: /* MY TXT File */ LINE2: (acturally i don't thin...

How can perltidy align the opening parenthesis for method arguments?

Hi, is there a possibility to make perltidy vertically align brackets like this: $foo->bar (1); $foo->bat (2); $foo->bac (3); $foo->bad (4); $foo->bae (5); $foo->baf ...

Perl: How can I call object methods inside END {} without warning?

package JustTesting; use strict; use warnings; sub new { my $self = {}; bless($self, shift); END { $self->goodbye() }; return $self; } sub goodbye { print "Goodbye.\n"; } package main; my $this = JustTesting->new(); Output: Variable "$self" will not stay shared at ./test line 10. Goodbye. Apparently it wo...

Where do I put persistent data in Catalyst?

I am writing a Catalyst web application that presents some data that does not change in between requests. I want to load this data when the application starts and stick them somewhere so that the relevant controllers can use them. Where should I load this data and where should I store it? At first I tried to load it in the main App.pm fi...

How can I determine if a script was called from the command line or as a cgi script?

I have a script that I wrote that can either be used on the command line or as a CGI script, and need to determine how the script was called so I can output a content-type header for web requests (and maybe some anti-cache headers too). My first thought is to check for the existance of http environment variables: my $js = build_javascri...

How can I elegantly call a Perl subroutine whose name is held in a variable?

I keep the name of the subroutine I want to call at runtime in a variable called $action. Then I use this to call that sub at the right time: &{\&{$action}}(); Works fine. The only thing I don't like is that it's ugly and every time I do it, I feel beholden to add a comment for the next developer: # call the sub by the name of $act...

In Perl, how can I find the index of a given value in an array?

$VAR1 = [ '830974', '722065', '722046', '716963' ]; How can I calculate the array index for the value "722065"? ...

How can I dynamically include Perl modules without using eval?

Hi, I need to dynamically include a Perl module, but if possible would like to stay away from eval due to work coding standards. This works: $module = "My::module"; eval("use $module;"); But I need a way to do it without eval if possible. All google searches lead to the eval method, but none in any other way. Is it possible to do it...

Perl within Python?

There is a Perl library I would like to access from within Python. How can I use it? FYI, the software is NCleaner. I would like to use it from within Python to transform an HTML string into text. (Yes, I know about aaronsw's Python html2text. NCleaner is better, because it removes boiler-plate.) I don't want to run the Perl program as...

Why does Git.pm on cygwin complain about 'Out of memory during "large" request?

Hi, I'm getting this error while doing a git svn rebase in cygwin Out of memory during "large" request for 268439552 bytes, total sbrk() is 140652544 bytes at /usr/lib/perl5/site_perl/Git.pm line 898, <GEN1> line 3. 268439552 is 256MB. Cygwin's maxium memory size is set to 1024MB so I'm guessing that it has a different maximum memor...

How can I quickly parse large (>10GB) files?

Hi - I have to process text files 10-20GB in size of the format: field1 field2 field3 field4 field5 I would like to parse the data from each line of field2 into one of several files; the file this gets pushed into is determined line-by-line by the value in field4. There are 25 different possible values in field2 and hence 25 different f...