perl

parallel skillset with perl

Hi, I'm a software engineer and has been working extensively on Perl. For in this competitive world I want to know what other skills are required with Perl to keep me up to the market. ...

Do Perl loop labels count as a GOTO?

Generally, it is good practice to avoid GOTOs. Keeping that in mind I've been having a debate with a coworker over this topic. Consider the following code: Line: while( <> ) { next Line if (insert logic); } Does using a loop label count as a goto? Here is what perlsyn in perldoc has to say: Here's how a C progra...

Perl pack use - double big endian ?

Hi, According to this calculator site (link text) , when converting 3 from dec to double I get 4008 0000 0000 0000 When using Perl pack function, with the parameter "d>*" , I expected to see 4008 0000 0000 0000 as I use this function: print $File pack("d>*",3); But when I "Hexdump" to the Perl output file, I see 0840 0000 0000 0000...

Nested foreach loop in perl only looping once.

I've written a perl script that opens two files which contain lists. I want to find items in the first list that are not in the second list. The script uses two foreach loops. The outer loop goes through each line of the first list, extracting the necessary item information. The inner loop goes through the second list, extracting the ite...

In perl how to distiniguish between CLI & CGI mode

Hi, I am suppose to write perl-CGI script, which supports CLI & CGI mode. And I am unable to find the way to distinguish between two mode. I am looking for the way to check for mode whether it is CLI or CGI ? So could you please let me know how to implement the logic? Thanks in advance. ...

Find the item in an array that meets a specific criteria if there is one (Perl)?

Is there a Perl idiom for finding the item in an array that meets a specific criteria if there is one? my $match = 0; foreach(@list){ if (match_test($_)){ $result = $_; $match = 1; last; } } $match || die("No match."); say $result, " is a match."; The example seems a bit awkward. I expect Perl to have som...

Can't run a Perl app

Although I can run test.cgi from the same location but app.cgi gives "Internal Server Error". I checked the permissions, chmoded 755 to everything. The app is located in domains root so the url will be domain.com/app.cgi This is the htaccess: AddHandler cgi-script .cgi Options +ExecCGI IndexIgnore * DirectoryIndex app.cgi RewriteEn...

Is there a perl module that can start a process and return the three main I/O handles to that process?

In perl, I often need to run a child process, send some input to it, and then read its output. There are a number of modules to do this, but they all seem to require you to pass in pre-existing variables, which are then modified by the function to contain filehandles. Here is an example from the Synopsis of IPC::Open3: my ($wtr, $rdr, $...

Why am I getting an unexpected return code?

I have a Perl script with the following code. ... $kill = 1; $exit = 0; `kill -9 $pid >& /dev/null`; ... print "kill=$kill exit=$exit\n"; if ($kill) { exit $exit; } else { ... In summary, this script uses open3() to run a command. At some point, it kills the job and then the intention is that the script will exit with code 0. I inse...

How to write a COM EXE for Win32 using Tcl and TclApp?

I would like to think it possible to use TclApp to create a Win32 EXE that could be used as COM server EXE. Has anyone tried this, or is it too horrible an idea to seriously consider? Basically, I want to do in Tcl what I can already do using PerlCtrl. ...

Perl Parallel::Forkmanager doesn't allow to collect variable values

Hi folks, Maybe because the child processes are not aware of my hash (see the below code), the hash %output is not collecting anything .. is there any other way to collect the value apart from writing a tmp file ? foreach $Item (@AllItems) { $pid = $pm->start($Item) and next; $Temp = qx($Item); $output{$Item}= $Temp; // This doesn't co...

How to cancel a file upload based on file size in Catalyst

I'm writing a file upload handler Catalyst. I'm trying to restrict the maximum file size. To do this I've made a Plugin (based on the answer here). Here is the code where I check for the file size: before 'prepare_body' => sub { my $c = shift; my $req = $c->request; my $length = $req->headers->{"content-length"}; if ($l...

How can I share data between threads?

I want to share data between two threads. How can we do that? Give some simple program. ...

why lost data when "print" data to socket

I'm using perl to write a socket based application. I found that if the client iniate two print on the socket handle in a way as below: print $sock "hello kitty"; #do some other stuff print $sock "hello jack"; the server side can't receive the whole message of "hello kitty". I'm not sure, but strongly suspicious that there are buffer ...

Multiple submit buttons in HTML::FormFu

Using formfu with catalyst. Don't really get how to do this. Can someone give short example please. Thanks ...

STDOUT redirected externally and no output seen at the console

Hi, I have a program which reads the output from external application.The external app gives set of output .My program reads the output from this external app while($line=) and print it to STDOUT.But the "print $line STDOUT" prints only some lines and when the error has occurred ,print to STDOUT is not working , but my one more logging ...

Perl Is it possible to re-create the Net::Telnet connection if I have its memory location ?

Hello, Is it possible to re-create the Net::Telnet connection if I have its memory location ? how can i turn Net::Telnet=GLOB(0x1b50ff0) string to a Net::Telnet object again ? Thanks. ...

How do I access HTTP request headers in HTTP::Server::Simple::CGI?

Hi! I'm using HTTP::Server::Simple::CGI for a light-weight HTTP server. That gives me a CGI object in a callback function when a HTTP request is accepted. How can I access the incoming HTTP headers, especially non-standard headers? The environment variables are only the standard ones. cgi->param gives me only the form parameters. Tha...

Configuring Selenium RC with Perl

I want to use Selenium RC with a Perl client driver. How can I configure Selenium RC with Perl? ...

Extracting Multilevel XML using Perl

hi all, I have a XML file as follow: <?xml version="1.0"?> <!DOCTYPE PubmedArticleSet PUBLIC "-//NLM//DTD PubMedArticle, 1st January 2010//EN" "http://www.ncbi.nlm.nih.gov/corehtml/query/DTD/pubmed_100101.dtd"&gt; <PubmedArticleSet> <PubmedArticle> <MedlineCitation Owner="NLM" Status="Publisher"> <PMID>20555148</PMID> ...