perl

Where can I find a current wxPerl PPM?

On September 24, 2009 Sep 24, 2009 wxPerl 0.93 was released to CPAN. Does anyone know where I can get a current ppm version of wxPerl 0.93 for Active Perl 5.10 The repositories (besides activestate.com) I know and visited are: wxperl.co.uk (last version Feb 2009) trouchelle.com (shows a fail status for Wx .93) cpan.uwinnipeg.ca (W...

Why does my perl one-liner ignore the first line of input?

I'm trying to strip some content from an HTML file automatically, and I'm using the following command to strip everything up to the useful data: perl -pi.bak -e 'undef $/; s/^.*?<pre>//s' $file However, for some reason this leaves the first line of the HTML file (the DOCTYPE declaration) alone. ...

Truth Table Generation for the given input

Hi all, I want to generate a truth table for the given input.Suppose if i give input 2 the output will be 10 01 11 00 if the input is 3 the output will be 111 000 110 101 011 100 001 010 i have a code snippet #!/usr/bin/perl #print "a|b|c\n"; for $a (1, 0){ for $b (1, 0){ for $c (1,0) { for $d ( 1,0) ...

How can I copy all files with a given extension?

I need to copy all *.exe files in some directory to other virtual drive . If I was writing batch script I would do xcopy "%mycopyposition%\*.exe". But I think it will be a bad idea in Perl script . I seen a File::Copy module, but couldn't see how to do that. ...

Is it possible to have Perl run shell script aliases?

Is it possible to have a Perl script run shell aliases? I am running into a situation where we've got a Perl module I don't have access to modify and one of the things it does is logs into multiple servers via SSH to run some commands remotely. Sadly some of the systems (which I also don't have access to modify) have a buggy SSH server t...

How can you pass undef as an argument to an object method from a TT template?

Template-Toolkit seems to want to always interpolate undef to the empty string. So a template like this: Result is [% some_object.some_method (1, undef, 2) %] or this: Result is [% ttvar %] [% some_object.some_method (1, ttvar, 2) %] produces a call to Perl like: some_object->some_method (1, '', 2) when what I want is:...

Perl's taint mode in PHP

Just wondering... is there a PHP equivalent to Perl's Taint Mode? I don't think there is, but thought I'd ask. ...

How can I replace the ISBN with the Google Books ID in a MARC file, using Perl?

I've got a file with some book data in MARC format, of which some lines are ISBNs. I'd like to replace these lines with the Google Books ID of that ISBN, if it exists. Here's the code so far, which just ends up removing the lines: perl -pe "s#ISBN(.*)#$(wget --output-document=- --quiet --user-agent=Mozilla/5.0 \"http://books.google.com/...

How can I extract a compressed archive in Perl?

I need to allow users to upload a zip file via a web form. The server is running Linux with an Apache web server. Are there advantages to using a module like Archive::Zip to extract this archive or should I just execute a system call to unzip with backticks? ...

Why do I see my Perl hash as a fraction, like '28/64'?

Hi. I'm trying to set key name in a hash to a string containig "/" symbols, for instance $myshash{"/dev/shm"} = "shared memory"; But what I get is something like '28/64' and so on when viewing with Data::Dumper. How can I use these special chars in hash key names? ...

How do I stop reading from a socket if the HTTP response doesn't have a Content-Length header?

The following code snippet reads HTTP response. Say the response doesn't contain a Content-Length header and the Content-Type is not text/html, how would one terminate the while loop? (1. Don't worry about chunked transfer encoding 2. No IO::Socket) while(defined($line = <SOCK>)) { $data .= $line; if($line =~ /Conte...

What's the fastest Perl IPC/message queue for a single machine?

I'm working on a (primarily) Perl project and want to use a message queue to isolate processes from each other. I have a work flow like this: Input -> Receiver -> Processor(s) -> Output(s) I need to handle several hundred transactions/second, so speed my biggest motivator. What is the fastest message queue system for this type of setup...

How can I convert the stringified version of array reference to actual array reference in Perl?

Is there any way to get Perl to convert the stringified version e.g (ARRAY(0x8152c28)) of an array reference to the actual array reference? For example perl -e 'use Data::Dumper; $a = [1,2,3];$b = $a; $a = $a.""; warn Dumper (Then some magic happens);' would yield $VAR1 = [ 1, 2, 3 ]; ...

What is the usefulness of CHECK, UNITCHECK and INIT blocks in Perl?

I know what they all do, but have never found myself in a situation where I've needed any of them. I've used BEGIN blocks on many occasions and ENDs once in a while. BEGIN is especially useful when you need to tweak the environment before code gets run, and I've used END in certain debugging situations to trap important state information...

Fastest Way To Find Mismatch Positions Between Two Strings of the Same Length

I have a millions of pairs of string of same length which I want to compare and find the position where it has mismatches. For example for each $str1 and $str2 we want to find mismatch position with $str_source: $str_source = "ATTCCGGG"; $str1 = "ATTGCGGG"; # 1 mismatch with Str1 at position 3 (0-based) $str2 = "ATACCGGC"...

How do I get the child process id in Parallel::ForkManager?

use LWP::Simple; use Parallel::ForkManager; @links=( ["http://prdownloads.sourceforge.net/sweethome3d/SweetHome3D-2.1-windows.exe","SweetHome3D-2.1-windows.exe"], ["http://prdownloads.sourceforge.net/sweethome3d/SweetHome3D-2.1-macosx.dmg","SweetHome3D-2.1-macosx.dmg"], ["http://prdownloads.sourceforge.net/sweethome...

How do I make OS X 10.6 compile JSON::XS as 32-bit instead of 64-bit?

I compiled Perl 5.10.1 under OS X 10.5. It was compiled as a 32-bit program. I have since upgraded to OS X 10.6. My version of Perl 5.10.1 continues to work fine, but I just tried to compile JSON::XS and got errors like the following: Can't load '/Users/cowens/.cpan/build/JSON-XS-2.26-clO6XX/blib/arch/auto/JSON/XS/XS.bundle' for m...

How do I set Excel formulas with Win32::OLE?

Hello, can anybody tell me, why the "...->{FormulaR1C1} = '=SUMME( "R[-3]C:R[-1]C" )';" doesn't work. In the Cell where should appear the result I get "#Wert!" ( maybe "Value" in English ). With the WENN(IF)-formula I get what I expect. #!C:\Perl\bin\perl.exe use warnings; use strict; use Win32::OLE qw; use Win32::OLE::Const 'Micro...

What Perl RESTful framework do you recommend?

Hi I'm looking for a Perl RESTful framework that have to : work under apache2/mod_perl2 be simple be elegant be light be flexible Am I just dreaming or can I avoid the 'Roll our own' approach? What framework would you recommend? ...

In perl, killing child and its children when child was created using open

Here's my code, with error handling and other stuff removed for clarity: sub launch_and_monitor { my ($script, $timeout) = @_; sub REAPER { while ((my $child = waitpid(-1, &WNOHANG)) > 0) {} $SIG{CHLD} = \&REAPER; } $SIG{CHLD} = \&REAPER; my $pid = fork; if (defined $pid) { if ($pid =...