perl

How do I protect quotes in a batch file?

I want to wrap a perl one-liner in a batch file. For (trivial) example, in a unix shell I could quote up a command like this: perl -e 'print localtime() . "\n"' But DOS chokes on that with the helpful Can't find string terminator "'" anywhere before EOF at -e line 1. What's the best way to do this within a .bat? ...

Deploying Perl to a share nothing cluster

Anyone have suggestions for deployment methods for Perl modules to a share nothing cluster? Our current method is very manual. Take down half the cluster Copy Perl modules ( CPAN style modules ) to downed cluster members ssh to each member and run perl Makefile.pl; make ; make install on each module to be installed Confirm deployment ...

EWOULDBLOCK equivalent errno under Windows Perl

G'day Stackoverflowers, I'm the author of Perl's autodie pragma, which changes Perl's built-ins to throw exceptions on failure. It's similar to Fatal, but with lexical scope, an extensible exception model, more intelligent return checking, and much, much nicer error messages. It will be replacing the Fatal module in future releases of...

How can I identify references to Java classes using Perl?

I'm writing a Perl script and I've come to a point where I need to parse a Java source file line by line checking for references to a fully qualified Java class name. I know the class I'm looking for up front; also the fully qualified name of the source file that is being searched (based on its path). For example find all valid referen...

Presentations on switching from Perl to Python

Short story: I'm looking for presentations/good articles on switching from Perl to Python. Longer story: I'm a programmer / embedded hardware engineer in a hardware design group. A few years ago I've convinced my co-workers to use Perl for scripting (instead of a weird mixture of batch files, Excel, Matlab and TCL). Since then, I myse...

How to search through archived files with Perl

What is your preferred method for reading through the contents of zipped directories with Perl ? ...

Where can I find a Perl module for converting a Perl data structure into a JavaScript one?

e.g. (Mason code): 16 % # convert our @cti data structure into a javascript one 17 var cti = [ 18 % foreach my $cti_category (@cti) { 19 { 20 label: "<% $cti_category->{'label'} %>", 21 value: "<% $cti_category->{'value'} %>", 22 children: [ 23...

What's the simplest way to make a HTTP GET request in Perl?

I have some code I've written in PHP for consuming our simple webservice, which I'd also like to provide in Perl for users who may prefer that language. What's the simplest method of making a HTTP request to do that? In PHP I can do it in one line with file_get_contents(). Here's the entire code I want to port to Perl: /** * Makes a r...

How can I find the version of an installed Perl module?

How do you find the version of an installed Perl module? This is in an answer down at the bottom, but I figure it important enough to live up here. With these suggestions, I create a function in my .bashrc function perlmodver { perl -M$1 -e 'print "Version " . $ARGV[0]->VERSION . " of " . $ARGV[0] . \ " is installed.\n"' $1 } ...

How can I get PHP's simplicity but Perl's power?

I despise the PHP language, and I'm quite certain that I'm not alone. But the great thing about PHP is the way that mod_php takes and hides the gory details of integrating with the apache runtime, and achieves CGI-like request isolation and decent performance. What's the shortest-distance approach to getting the same simplicity, speed ...

How do I profile a Perl web app?

I am working on a web app that uses Perl and I need to look into speeding up portions of the app. I thought I'd start profiling the particular calls for the portion I wish to investigate. I've done some searching on profiling Perl code, but unfortunately most of what I find says that I should run my perl code with -d:DProf myapp from...

How do I make this "Use of uninitialized value" warning go away?

Let's say I want to write a regular expression to change all <abc>, <def>, and <ghi> tags into <xyz> tags.. and I also want to change their closing tags to </xyz>. This seems like a reasonable regex (ignore the backticks; StackOverflow has trouble with the less-than signs if I don't include them): `s!<(/)?(abc|def|ghi)>!<${1}xyz>!g;` ...

What's the point of Perl's map?

Not really getting the point of the map function. Can anyone explain with examples its use? Are there any performance benefits to using this instead of a loop or is it just sugar? ...

Compressing HTTP request with LWP, Apache, and mod_deflate

I have a client/server system that performs communication using XML transferred using HTTP requests and responses with the client using Perl's LWP and the server running Perl's CGI.pm through Apache. In addition the stream is encrypted using SSL with certificates for both the server and all clients. This system works well, except that ...

Truncate stdin line length?

I've been parsing through some log files and I've found that some of the lines are too long to display on one line so Terminal.app kindly wraps them onto the next line. However, I've been looking for a way to truncate a line after a certain number of characters so that Terminal doesn't wrap, making it much easier to spot patterns. I wro...

Is there a way to have managed processes in Perl (i.e. a threads replacement that actually works)?

I have a multithreded application in perl for which I have to rely on several non-thread safe modules, so I have been using fork()ed processes with kill() signals as a message passing interface. The problem is that the signal handlers are a bit erratic (to say the least) and often end up with processes that get killed in inapropriate st...

How can I do a full-text search of PDF files from Perl?

I have a bunch of PDF files and my Perl program needs to do a full-text search of them to return which ones contain a specific string. To date I have been using this: my @search_results = `grep -i -l \"$string\" *.pdf`; where $string is the text to look for. However this fails for most pdf's because the file format is obviously not AS...

Perl - Win32 - How to do a non-blocking read of a filehandle from another process?

I'm writing some server code that talks to a client process via STDIN. I'm trying to write a snippet of perl code that asynchronously receives responses from the client's STDOUT. The blocking version of the code might look like this: sub _read_from_client { my ($file_handle) = @_; while (my $line = <$file_handle>) { print ST...

What constitutes effective Perl training for non-Perl developers?

I've been working with Perl long enough that many of its idiosyncracies have become second nature to me. When new programmers join our group, they frequently have little to no experience with Perl, and it's usually my task to train them (to the extent necessary). I'd like to know what to focus on when training a programmer who is new t...

Which scripting language should I learn after Perl?

Hi, I have used Perl for many years now, mostly for doing all kinds of file parsing and system scripting jobs. Several newer scripting languages (python, ruby) are now available, that all in part tend to address scripting etc. in a better way than Perl apparently did. If I would have to choose learning a new scripting language, which ...