perl

Named Pipes IPC

I am trying to create a pipe to use between two processes to send information. The two process are not related and implementation with signals has a problem where if the process that recieves the signal is doing a sys command it intreprets the signal as an intrupt. I am new to perl so any help trying to have two processes use pipes woul...

What is Perl's "standard string comparison order"?

This is really a double question, my two end goals having answers to: What is the standard string comparison order, in terms of the mechanics? What's a better name for that so I can update the docs? Perl's documentation for sort says that without a block, sort uses "standard string comparison order". But what is that order? There sho...

How do I get the current working directory in Net::FTP if its name has a space?

I'm using Net::FTP to put a file on a remote server. I need to put the file in a folder whose name contains a space character. The cwd() method seems to not like the following arguments and nothing seems to work. $ftp->cwd('My Folder') $ftp->cwd('"My Folder"') $ftp->cwd('\"My Folder\"') Has anyone done this before? How do I cwd into ...

How can I extend Moose's automatic pragma exports?

You know how Moose automatically turns on strict and warnings during import? I want to extend that behavior by turning on autodie and use feature ':5.10' in my Moose classes. I've tracked down where Moose does this, in Moose::Exporter, which assembles a custom import sub for Moose that calls strict->import and warnings->import for the c...

How can I figure out why my Perl script crashes?

I have written a Perl script that sends data to clients. It works some time (from one minute to 2 hours) and then goes down. No errors in console, no errors in log. I added an END section to it - it isn't executed. What can I do to figure out what the problem is? ...

Reading content from Multiple Text Files

Looking for help in doing this: I have a directory full of text files that are named with a numerical ID. Each text file contains the body of a news article. Some news articles are segregated in different parts, so they are in different text files. The names are such 1001_1.txt, 1001_2.txt (These files contain two different pa...

How do I create a session in Catalyst?

Trying to figure our how to create, store and retrieve session info in Catalyst. Any suggestions? ...

How can I accept mail from only one domain in smtp-gated?

I need a Perl-compatible regular expression for filtering my email with smtp-gated. I only want to allow one domain ('mydomain.com') and reject everything else. How do I do this in a foolproof way? (regex_reject_mail_from) I know this question halfway belongs on serverfault, but basically it's a Perl regex question so I think it fits st...

Do you develop your Perl applications as CPAN modules?

Recently I read a blog post saying that it is a good practice to develop Perl applications just as you would develop a CPAN module. (Here it is – thanks David!) One of the reasons given was that you could simply run cpan . in the project dir to install all the dependencies. This sounds reasonable, and I also like the “uniform interface” ...

Why does Perl complain about "Use of uninitialized value" in my CGI script?

I am cleaning my Perl code for production release and came across a weird warning in the Apache error log. It says: [Thu Nov 5 15:19:02 2009] Clouds.pm: Use of uninitialized value $name in substitution (s///) at /home/mike/workspace/olefa/mod-bin/OSA/Clouds.pm line 404. The relevant code is here: my $name = shift @_; my $nam...

How do I suppress the default apache error document in mod_perl?

I'm developing a RESTful API and I wrote a mod_perl2 handler that takes care of the request. My handler deals with error codes by setting $r->status($http_code) and return $http_code; Everything is fine, except a little problem: when my http_code is different than 200 (for instance 404), apache appends a default HTML error document to ...

Perl DBI MySQL Error Msg : Can't call method "do" on an undefined value

I am trying to run simple perl dbi example script to connect to mysql database and do some inserts. Code: #! bin/usr/perl -w use strict; use warnings; use DBI(); my $dbh = DBI->connect( "DBI:mysql:database=SPM;host=IP Address", "username", "password", {'RaiseError'=>1} ); my $dbh->do( 'INSERT INTO payment_methods(name, ...

Checking existence of a file given a directory format in perl

I am struggling with a method of walking a directory tree to check existence of a file in multiple directories. I am using Perl and I only have the ability to use File::Find as I am unable to install any other modules for this. Here's the layout of the file system I want to traverse: Cars/Honda/Civic/Setup/config.txt Cars/Honda/Pathfi...

How does Perl decide which order to evaluate terms in an expression?

Given the code: my $x = 1; $x = $x * 5 * ($x += 5); I would expect $x to be 180: $x = $x * 5 * ($x += 5); #$x = 1 $x = $x * 5 * 6; #$x = 6 $x = 30 * 6; $x = 180; 180; But instead it is 30; however, if I change the ordering of the terms: $x = ($x += 5) * $x * 5; I do get 180. The reason I am confused is that perldoc per...

making LWP Useragent faster

I need to perform a large number of HTTP post requests, and ignore the response. I am currently doing this using LWP::UserAgent. It seems to run somewhat slow though I am not sure if it is waiting for a response or what, is there anyway to speed it up and possibly just ignore the responses? ...

Why can't I have a literal list slice right after a print in Perl?

I see I can do something like this: print STDOUT (split /\./, 'www.stackoverflow.com')[1]; and "stackoverflow" is printed. However, this: print +(split /\./, 'www.stackoverflow.com')[1]; does the same, and this: print (split /\./, 'www.stackoverflow.com')[1]; is a syntax error. So what exactly is going on here? I've always under...

Will data in a pipe queue up for reading by Perl?

I have a Perl script that executes a long running process and observes its command line output (log messages), some of which are multiple lines long. Once it has a full log message, it sends it off to be processed and grabs the next log message. open(PS_F, "run.bat |") or die $!; $logMessage = ""; while (<PS_F>) { $lineRead = $_; ...

Parse HTML Page For Links With Regex Using Perl

Possible Duplicate: How can I remove external links from HTML using Perl? Alright, i'm working on a job for a client right now who just switched up his language choice to Perl. I'm not the best in Perl, but i've done stuff like this before with it albeit a while ago. There are lots of links like this: <a href="/en/subtitles/35...

How can I read key input on windows in Perl?

I want to develop some utility on perl for autocompleting words. Is there any effective way in Perl to hook the keyboard on win32 (thread hook/surelly not system hook ) and catch an event when a key is clicked? I want to intercept the keyboard before the message sent to the OS like setwindowshookex win32 api and to process the message ...

Can I use Perl's map with an array slice?

I'm just trying to shorten a line of code that assigns HTML::Element->as_trimmed_text from an array of HTML::Elements to some variables - pretty standard stuff like: my ($var1, var2) = ($columns[1]->as_trimmed_text, $columns[2]->as_trimmed_text); ..except that there's a few more columns so it continues on over a few more lines. I had ...