perl

How to send web browser a loading page, then some time later a results page

I've wasted at least a half day of my company's time searching the Internet for an answer and I'm getting wrapped around the axle here. I can't figure out the difference between all the different technology choices (long polling, ajax streaming, comet, XMPP, etc.) and I can't get a simple hello world example working on my PC. I am runn...

PHP to C/C++ through CGI script

Hi guys! I realize it's probably something strange, but here is what I have. I have an application (handwriting recognition engine) written in C/C++. This application has Perl wrapper which was made by application's authors using SWIG. My website is written in PHP, so I'm looking for some ways to make PHP work with C/C++ application. ...

Given the full path to a file, how do I get just the path without the filename?

Hello, Suppose I have a path in a string called '/home/user/directory/HelloWorld.txt'. I would like to remove the HelloWorld.txt, and end up with '/home/user/directory'. What regex would I need. ...

How do I remove duplicate characters and keep the unique one only in Perl?

How do I remove duplicate characters and keep the unique one only. For example, my input is: EFUAHUU UUUEUUUUH UJUJHHACDEFUCU Expected output is: EFUAH UEH UJHACDEF I came across perl -pe's/$1//g while/(.).*\/' which is wonderful but it is removing even the single occurrence of the character in output. ...

How do pass arguments to subroutines in Perl/Tk?

I have designed one sign-up form,in this form after getting all necessary values I will click submit button. And while clicking that submit button I want to call one function and I want to pass the arguments to that function. I have written code for this purpose,but the function is called first before getting the details.(i.e)after get...

How do I find the difference between normal text and the JSON encoded text in Perl?

I have used JSON::Any in my program to transfer the hash between client and server. I faced one problem, I want to find whether the text (sent by client) is normal text or JSON encoded text. Can anyone please tell me how to find, without checking, I got some error in server side and it is closed. ...

How can I run my perl CGI script without apache?

How can I run my perl CGI script without apache? This is for testing purposes, so some kind of single-process server that processes only one request at time should be enough for me. ...

Why is this statement treated as a string instead of its result?

I am trying to perform some composition-based filtering on a large collection of strings (protein sequences). I wrote a group of three subroutines in order to take care of it, but I'm running into trouble in two ways - one minor, one major. The minor trouble is that when I use List::MoreUtils 'pairwise' I get warnings about using $a and...

How to use perl for SMTP connection with user and SSL Auth and send emails with attachment

I am using a SMTP mail server which require user + ssl authentication for connection. I am looking for the perl modules to connect to the mail server and send emails but doesn't found anything helpful. Any suggestion for perl module or any perl code would be really appreciated. EDIT I have tried to use Mail::Sendmail and Net::SMTP::S...

Split PDF documents into separate pages using PHP (or possibly perl)

Can anybody point me towards a PHP library or script that would allow me to split a pdf consisting of multiple pages into separate files, each containing 1 page. The PDFLib documentation doesn't appear to allow this and Google hasn't been particularly helpful. I could possibly also use Perl, but it would be very inconvenient to do so. ...

How can I take a reference to a Perl subroutine?

I'm having some trouble figuring out how to make a reference to a subroutine in an external module file. Right now, I'm doing this: External file package settingsGeneral; sub printScreen { print $_[0]; } Main use settingsGeneral; my $printScreen = settingsGeneral::printScreen; &$printScreen("test"); but this result int...

How can I restore STDOUT after redirecting it to a file in a Perl script?

Below is the part of my code, my code enters "if loop" with $value =1 and output of the process iperf.exe is getting into my_output.txt. As I am timing out the process after alarm(20sec) time, also wanted to capture the output of this process only. Then after i want to continue to the command prompt but i am not able to return to the c...

How can I tell if Log4perl emitted any warnings during a run?

I've been using Log4perl extensively in a number of scripts. I'd like to augment those scripts to set an error code if any WARN or ERROR messages have been logged. I couldn't find any obvious way to do this based on existing documentation. I'd like to avoid a brute-force rewrite of my existing scripts to add a check on every WARN or ER...

How can I mark a radio button as checked using Perl?

I try to create a form that can save a person's form data so that he can later finish completing the form. I have no problem to save the data to an external file and I know that it would be easy to do what I try to do if the user was permitted to save his data only once a full page form was completed. However, I want to be able to save t...

A 'do' statement at the end of my perl script never runs

In my main script, I am doing some archive manipulation. Once I have completed that, I want to run a separate script to upload my archives to and FTP server. Separately, these scripts work well. I want to add the FTP script to the end of my archive script so I only need to worry about scheduling one script to run and I want to guarantee...

When opening a file in perl, how can I automatically use STDIN/OUT if the file name is "-"?

I have a perl program that takes input and output file arguments, and I'd like to support the convention of using "-" to specify standard input/output. The problem is that I can't just open the file name, because open(my $input, '<', '-') opens a file called -, not standard input. So I have to do something like this: my $input_fh; if ($...

How do I receive and respond to Ajax requests in Perl?

I have a client-side appliction which submits some data via AJAX POST request (request.open("POST", url, flag)) to my Perl CGI script. How do I retrieve this data with Perl and return some other data (AJAX response)? ...

How can I efficiently group a large list of URLs by their host name in Perl?

I have text file that contains over one million URLs. I have to process this file in order to assign URLs to groups, based on host address: { 'http://www.ex1.com' => ['http://www.ex1.com/...', 'http://www.ex1.com/...', ...], 'http://www.ex2.com' => ['http://www.ex2.com/...', 'http://www.ex2.com/...', ...] } My current basic s...

Which module should I use to parse mediawiki text into a Perl data structure?

I just need to parse the wikitext into Perl arrays of hashes. I found several modules. The Text::MediawikiFormat seems to be what I need, but it returns HTML, and I want a Perl data structure. I also looked at: Parse::MediaWikiDump Text::WikiText Convert::Wiki ...

How can I print the calling program/module inside a method in Perl?

I have written a Perl API and it is used by many programs across teams. I want to track all programs calling my API method. I want to have something like the below debug("The calling method is ", $XXXX); How to get $XXXX ? ...