perl

How can I specify timeout limit for Perl system call?

Sometimes my system call goes into a never ending state. To, avoid that I want to be able to break out of the call after a specified amount of time. Is there a way to specify a timeout limit to system? system("command", "arg1", "arg2", "arg3"); I want the timeout to be implemented from within Perl code for portability, and not using ...

Getopt::Long Pushing multiple values in a hash option

For Example : use Getopt::Long; %file ; GetOptions('file=s%' => sub { push(@{$file{$_[1]}}, $_[2]) }); use Data::Dumper ; print Dumper %file ; print @{$file{filename}} ; my @file_array = @{$file_ref}; print "==\n @file_array == "; I can execute and it working : perl multipls.pl --file filename=a.txt --file filename=b.txt ...

Is this a bug in the CPAN Uniq module?

use Uniq; my @test1 = ("0","0","A"); my @test2 = ("1","1","A"); @test1 = uniq sort @test1; @test2 = uniq sort @test2; print "$_" for @test1; print "\n"; print "$_" for @test2; print "\n"; returns : 00A 1A It should be 0A or not?! Thank you ...

Why does Perl's Net::SFTP->new complain about "Not an ARRAY reference"?

I am trying to use Net::SFTP to get connected to remote server. My script is: my %args = ( ssh_args => { user => 'canneu_scp', identity_files => [ '/home/home1/cgrshah/responsys/capgemini.private' ], debug => 1, } ); my $targetserver='files.responsys.net'; my $sftp = Net::SFTP->new($targetserver, %args)...

How can I convert plain text to HTML (preferably using Perl)?

Is there a way to take a plain text file and convert it to a simple HTML? A couple of 'sophisticated' stuff that will be great identify hyper-links. identify (tab delimited) tables. UPDATE I just found this HTML::FromText. Checking to see if it meets my needs... ...

How can I send data from Yahoo quotes to MySQL with Perl?

After I download data from Yahoo and Google finance, how I do use a Perl script to send these to MySQL database automatically? ...

How can I create a unique value in Perl for each record I fetch from MySQL?

How can I produce a unique value key to be paired with my _rec_key_ field name? I am producing a datafile. I was looking at using an MD5 value as my key or any other suggestions you have to making sure this is unique. I'm not familiar with how to extract this value. The format of the file should look something like this: __rec_key__^a...

How can I get my Perl regex not to use special characters from an interpolated variable?

Possible Duplicate: How can I escape meta-characters when I interpolate a variable in Perl's match operator? I am using the following regex to search for a string $word in the bigger string $referenceLine as follows : $wordRefMatchCount =()= $referenceLine =~ /(?=\b$word\b)/g The problem happens when my $word substring cont...

How can I print a message for each substitution in my Perl one-liner?

I use the following Perl syntax in my bash script: perl -i –pe 'next if /^ *#/; s/(\b|\D)$ENV{OLD }(\b|\D)/$1$ENV{NEW }$2/' file I want to find the OLD word without first "#" character in the file , then replaces the OLD word with NEW word My question: I want to print "replace $OLD with $NEW" each time perl replace the $OLD ...

How can I parse command line arguments?

I want to parse a list of arguments in a perl script, for example i have this situation : script.pl -h 127.0.0.1 -u user -p pass arg1 arg2 arg3 How can i do for parse the list of argument that aren't option in an array, and the option parameter in scalar value ? Thanks. ...

How do I create a Perl regex that matches non-alphanumeric characters except spaces?

I have a Perl regex /\W/i which matches all non-alphanumeric characters, but it also matches spaces which I want to ignore. How do I get it to match non-alphanumeric characters except spaces? ...

What's the best library for parsing RSS/Atom in Perl?

I notice that XML::RSS::Parser hasn't been updated since 2005. Is this still the recommended library for parsing RSS or Atomtom? Is there a better one or a better way? ...

How can I limit the number of returned items in Perl's split?

I got a problem when I parse a complex file which include thousands of lines. I already implemented my Perl script like this days ago. my ($head, $tail) = split /=/, $line; Nearly all my source file $line style as below: constant normalLines = <type value> /* hello world */ and I can get the output $tail = /* hello world ...

(3 lines) from bash to perl?

I have these three lines in bash that work really nicely. I want to add them to some existing perl script but I have never used perl before .... could somebody rewrite them for me? I tried to use them as they are and it didn't work note that $SSH_CLIENT is a run-time parameter you get if you type set in bash (linux) users[210]=radek ...

Can I use the `Win32::GUI` to create a system tray icon for my command prompt Perl program?

I have a Perl script that is running an infinite loop. I'd like to be able to minimize this to the system tray. Can I use the Win32::GUI to create a system tray icon that when maximized shows the command prompt and the output of the script? Edit: My perl script is a process by itself. Its running continuously. How can I run the systray...

How to convert .xlsx to .txt?

I want to know if there is a linux tool or a script available to convert xlsx file to .txt. Thanks. ...

How can I check if HTML contains extended entities like &lt;?

Let's say we have a html string like "2 &lt; 4" How should be determined if it contains any of these extended sequences? I 've found HTML::Entities on CPAN, but it doesn't provide 'check' method. Details: fixing 'truncate' method in a way to not leave corrupted string like "2 &l" and not to do unnecesary work. It should look like this...

How can I create a structure after a Moose object was initialized?

I'm using Moose to write an object module. I currently have a few mandatory fields: has ['length'] => ( is => 'ro', isa => 'Int', required => 1, ); has ['is_verified'] => ( is => 'ro', isa => 'Bool', required => 1, ); has ['url'] => ( is => 'ro', isa => 'Str', requi...

Why does Perl's Win32::OLE complain about "Invalid index" for an Excel worksheet?

Code # get already active Excel application or open new my $Excel = Win32::OLE->GetActiveObject('Excel.Application') || Win32::OLE->new('Excel.Application', 'Quit'); # open Excel file my $Book = $Excel->WorkBooks->Open($file); # select worksheet number. Default is 1 (you can also select a worksheet by name) print "worksheet $wo...

Which Perl web framework should I use for a static HTML application?

I am about a develop a simple web application (5-6 static pages). Is there a framework I could use for this? I can just write these HTML pages without a framework but I would like a framework as it will better handle header, footer, and CSS throughout the website. I have a Perl script that will be modifying these HTML pages daily. And I...