perl

How can I import Perl code from external files at compile time?

Help Perlers! Does anyone know a simple "insert code here" approach would bring code from external files once at compile time into a package? Background: I have a standard PBP-style inside-out class that is getting quite large. I want to split the code into multiple files but not extend the class. Optimally, I would simply insert th...

Is there a cloud infrastructure where I can deploy Perl applications?

Is there a online/cloud-ish app engine with an available Perl option? I'd like to write and deploy a personal web app that's hosted by some existing web App engine (the app's fairly simple and resource-cheap, but does need small online storage. If anyone cares, it's basically a family-scope shopping list to be used off of smartphones an...

Schliemann's method of programming language learning

Background: 19th-century German archeologist Heinrich Schliemann was of course famous for his successful quest to find and excavate the city of Troy (an actual archeological site for the Troy of Homer's Iliad). However, he is just as famous for being an astonishing learner of languages - within the space of two years, he taught himself...

How do I dereference a Perl hash reference that's been passed to a subroutine?

I'm still trying to sort out my hash dereferencing. My current problem is I am now passing a hashref to a sub, and I want to dereference it within that sub. But I'm not finding the correct method/syntax to do it. Within the sub, I want to iterate the hash keys, but the syntax for a hashref is not the same as a hash, which I know how t...

Python for a Perl programmer

I am an experienced Perl developer with some degree of experience and/or familiarity with other languages (working experience with C/C++, school experience with Java and Scheme, and passing familiarity with many others). I might need to get some web work done in Python (most immediately, related to Google App Engine). As such, I'd like ...

How can I get the column names when querying with DBI in Perl?

I'm using DBI to query a SQLite3 database. What I have works, but it doesn't return the columns in order. Example: Query: select col1, col2, col3, col4 from some_view; Output: col3, col2, col1, col4 3, 2, 1, 4 3, 2, 1, 4 3, 2, 1, 4 3, 2, 1, 4 ... (values and columns are just for illustration) I know this i...

How can I install HTML-Parser-3.64 on Perl 5.6?

I am trying to install HTML-Parser-3.64 and I get following report while running make test: ERL_DL_NONLAZY=1 /home/Perl/bin/perl -Iblib/arch -Iblib/lib -I/home/Perl/5.6.1-nothread/lib/perl5/5.6.1/sun4.SVR4 -I/home/Perl/5.6.1-nothread/lib/perl5/5.6.1 -e 'use Test::Harness qw( $verbose=0; runtests @ARGV;' t/*.t t/api_version........ok ...

How can I capture the group of digits at the end of a string in Perl?

I'm trying to capture the last digits in this line in a regex group: The input: 9 Power_On_Hours 0x0032 099 099 000 Old_age Always - 54654 My pattern: /Power_On_Hours.+Always\s.+([0-9]{1,5})/ I just can't seem to get it to capture "54654", it's returning undef :( ...

How do I write a Perl regular expression that will match a string with only these characters?

I am pretty new to regular expressions. I want to write a regular expression which validates whether the given string has only certain characters. If the string has any other characters than these it should not be matched. The characters I want are: & ' : , / - ( ) . # " ; A-Z a-z 0-9 ...

How can I include a variable in a Perl printf expression?

How can I include a variable in a printf expression? Here's my example: printf "%${cols}s", $_; Where $cols is the number of columns and $_ is a string. The statement results in an "Invalid conversion" warning. The problem ended up being that I forgot to chomp the variable. Gah. Thanks everyone. ...

Why does Perl's IO::Socket on Windows complain about "Resource Not Available" after 64 connections?

I created a server with Perl under Windows (ActivePerl 5.10.1 build 1006) that forks upon being connected to, accepts some JSON data, and writes it to a database. I am running into a problem after 64 clients connect to the server, the error message being "Resource is not available" when trying to fork. Running this code under Linux I f...

Creating random XML entries in Java or Perl

Hello I am looking for a method to insert random XML data in Java (or Perl). <vehicles ID="DJ3RKFF9"> <vehicle> <make>Toyota</make> <model>Yaris</model> <year>2009</year> </vehicle> <vehicle> <make>Ford</make> <model>Taurus</model> <year>2008</year> </vehicle> </vehicles> ...

Why is there so much "magic" in Perl?

I'm looking through perlop and perlsub pages of the Perl manual. There are many references about "magic" and "magical" here (just search any of them for the "magic"). I wonder why is Perl so rich in them. Some examples: print ++($foo = 'zz') # prints 'aaa' printf "%d: %s", $! = 1, $! # prints '1: Operation n...

Perl Regular Expressions to match a MD5 Hash?

Recently programming in PHP, I thought I had a working Perl regular expression but when I checked it against what I wanted, it didn't work. What is the right expression to check if something is a MD5 has (32 digit hexadecimal of a-z and 0-9). Currently, I have /^[a-z0-9]{32}$/i ...

How can I forward information to another website and obtain its response in Perl?

In a Perl script (with Ubuntu) I'd like to do something like use Blah; ... ... my $response = &Blah::Fetch($URL, {'method'=>'POST', 'parameters' => \%params}); which I've written for convenience to look a lot like a Prototype.js ajax call, but obviously we're using Perl not Javascript, we're on a server not a ...

How can I use a Perl one-liner to decode an ASCII string encoded in hex?

I’d like to write a Perl one-liner to decode a line of ASCII characters encoded as hexadecimal numbers (for example the line 48 54 54 50 should be decoded as HTTP). I came up with this: perl -nE 'say map(chr, map { qq/0x$_/ } split)' It prints an empty line. What am I doing wrong and how would you write it? ...

What does “select((select(s),$|=1)[0])” do in Perl?

Possible Duplicate: What does select((select(s),$|=1)[0]) do in Perl? What's the purpose of the second line ? open my $fh, '>>', $logfile or die $!; select((select($fh), $|=1)[0]); ...

How to efficiently call Perl program from Java?

I am trying to run a Perl program in Java. I'm using: process = Runtime.getRuntime().exec("getComps.pl"); but it is giving: Exception: java.io.IOException: Cannot run program "getComps.pl": CreateProcess error=193, %1 is not a valid Win32 application I have also tried: process = Runtime.getRuntime().exec("cmd /c start ge...

C++ - How to read Unicode characters( Hindi Script for e.g. ) using C++ or is there a better Way through some other programming language?

Hi:) I have a hindi script file like this: 3. भारत का इतिहास काफी समृद्ध एवं विस्तृत है। I have to write a program which adds a position to each and every word in each sentence. Thus the numbering for every line for a particular word position should start off with 1 in parentheses. The output should be something like this. 3. भारत...

How can I match a tab to the end of the line with a Perl regex?

I have a file with the below contents: After learning everything you've learned so far, you may think you've bingo: got a pretty good foundation in programming Perl, since you'd already be a good way through most of the concepts many other languages entail. endbingo: But if you put down this book today and did nothing else bingo: ...