perl

Perl 'system' failure messages

Say I have this perl "program" called simple.pl: #!/usr/bin/perl use xyz; # xyz is bogus and doesn't exist And I also have this "program", called simple2.pl: #!/usr/bin/perl system("simple.pl"); my $abc = `simple.pl`; printf("abc %s\n", $abc); for both system and backtick, I get this message: Can't exec "simple.pl": No such file ...

Perl daemon script for message queue hanging for 20 seconds after each process. Why?

I have daemon script written in Perl that checks a database tables for rows, pulls them in one by one, sends the contents via HTTP post to another service, then logs the result and repeats (only a single child). When there are rows present, the first one is posted and logged immediately, but every subsequent one is delayed for around 20 ...

Storing array as value in associative array

i have a problem where I need to have an array as a value in an associative array. Go through the code below. Here I am trying to loop the files in a directory and it is more likely that more than 1 file can have the same ctrno. So, I would like to see what are all the files having the same ctrno. The code below gives error at "$ctrn...

How can I dynamically build a Java classpath in Perl?

For Example in shell script: _CLASSPATH =. for jar in lib/*.jar do _CLASSPATH=${_CLASSPATH}:${jar} done How can I dynamically build a Java classpath in Perl? ...

A problem in socket programming in perl

I write this code : #!/usr/local/bin/perl use strict; use LWP::UserAgent; my $ua = new LWP::UserAgent(agent => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.5) Gecko/20060719 Firefox/1.5.0.5'); $ua->proxy([qw(http https)] => 'http://203.185.28.228:1080' #that is just socks:port); my $response = $ua->get("http://www.g...

Read and Write in the same file with different process

I have written the two program. One program is write the content to the text file simultaneously. Another program is read that content simultaneously. But both the program should run at the same time. For me the program is write the file is correctly. But another program is not read the file. I know that once the write process is co...

SIMPLE file reading in Perl

Hey guys, The other answered questions were a bit complicated for me, as I'm extremely new to using Perl. I'm curious how Perl reads in the files, how to tell it to advance to the next line in the text file, and how to make it read all lines in the .txt file until, for example, it reaches item "banana". Any and all help would be appre...

What is this Perl code using LWP::UserAgent doing?

i have this code : use strict; use LWP::UserAgent; use warnings; my $ua = new LWP::UserAgent(agent => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.5) Gecko/20060719 Firefox/1.5.0.5'); $ua->proxy([qw(http https)] => 'http://59.39.92.148:1080'); my $response = $ua->get("http://www.google.com"); print $response->code,' '...

Can I run perl unit tests under ant jUnit task? How can I handle perl unit tests errors within ant build script?

I'd like to deploy my set of perl scripts by ant. I'm going to run perl test scripts in the ant build.xml and I want to handle perl errors. That's why I wonder, how does ant task work? Does junit parse output of tests? In this case I can transform TAP output within TAP::Formatter::JUnit CPAN module. http://search.cpan.org/dist/TA...

WWW::Mechanize::Plugin::Display - Always open a new window

How can I configure WWW::Mechanize::Plugin::Display, so that the plug-in always opens a new window and not only a new tab? ...

How can I use Perl to get a SHA1 hash of a file from the Windows command line?

I have a file called secure.txt in c:\temp. I want to run a Perl command from the command line to print the SHA1 hash of secure.txt. I'm using ActivePerl 5.8.2. I have not used Perl before, but it's the most convenient option available right now. ...

PERL XPath Parser Help

I want to pull in data using a XML::XPath parser from a XML DB file from the Worldbank site. The problem is that I'm not seeing any results in the output. I must be missing something in the code. Ideally, I would like to extract just the death rate statistics from each country XML DB (year and value). I'm using this as part of my input: ...

Can I find a filename from a filehandle in Perl?

open(my $fh, '>', $path) || die $!; my_sub($fh); Can my_sub() somehow extrapolate $path from $fh? ...

How can I replace some HTML tags based on their class in Perl?

I need replace some tags in HTML using Perl: I have this: <span class="a">text</span><span class="a">text</span><span id="b">text</span> I need this, where the span tags with class=a are changed to b tags instead: <b>text</b><b>text</b><span id="b">text</span> I tried using HTML::Manipulator but did not succeed. ...

Is there a Perl module for parsing numbers, including ranges?

Is there a module, which does this for me? sample_input: 2, 5-7, 9, 3, 11-14 #!/usr/bin/env perl use warnings; use strict; use 5.012; sub aw_parse { my( $in, $max ) = @_; chomp $in; my @array = split ( /\s*,\s*/, $in ); my %zahlen; for ( @array ) { if ( /^\s*(\d+)\s*$/ ) { $zahlen{$1}++; } e...

TripleDES in Perl/PHP/ColdFusion

Recently a problem arose regarding hooking up an API with a payment processor who were requesting a string to be encrypted to be used as a token, using the TripleDES standard. Our Applications run using ColdFusion, which has an Encrypt tag - that supports TripleDES - however the result we were getting back was not what the payment proces...

How can I open a download popup for all kind of files in my Perl CGl script?

On my application, the user needs to click on a file name, and then the user is supposed to choose either to download the file or open it. I put code for it that is working fine for .doc, .txt extentions yet it is not working fine for .docx My code is the following: @header('Location:'.$attachment_path); Any idea of how to do it so ...

How can I change some specific carps into croaks in Perl?

I tried to catch a carp-warning: carp "$start is > $end" if (warnings::enabled()); ) with eval {} but it didn't work, so I looked in the eval documentation and I discovered, that eval catches only syntax-errors, run-time-errors or executed die-statements. How could I catch a carp warning? #!/usr/bin/env perl use warnings; use str...

How can I comment out only part of a line in Perl?

How do I comment a part of a single line in Perl, like the following line: if($clevel==0){#never happends} I would like to be able to comment that last closing bracket, without going to a new line. ...

Implementing a lock using simple files

I would like to know if there is any way a file can be moved only if the destination does not exist - in other words, move only if it does not lead to overwriting. mv --update seemed first to be the solution, however, if the timestamp of the source path is newer than the destination, move will overwrite it and all attempts to circumve...