perl

How can I close a Windows CMD window after I run a Perl program?

Is there a way to close a cmd window when a task is complete and also tell how many are already open? system( qq{ start "List Perl files" perl c:/perlscripts/new_spider.pl $new_href } ) ...

Why does my Perl recursive function never end?

I'm trying to write the following recursive function. The problem is that it never ends and I can't understand why: sub do_smth(@first, @second){ my @tmp_first = @first; $tmp = shift(@tmp_first); if (@tmp_first > 0){ do_smth(@tmp_first, @second); } my @tmp_second = @second; $tmp = shift(@tmp_second)...

How can I run multiple jobs from a large queue at the same time in Perl?

I would like to program bsub job limits into my Perl script which launches lsf jobs under the hood. If I have something like 2000 jobs, I would like to run at max 20 jobs at any given time. I would prefer that the jobs running is max 20. I seen scripts where people launch 20 jobs and wait for it to finish before launching another 20. ...

Can I get fcntl and Perl alarms to cooperate?

I'm on linux, nfs, with multiple machines involved. I'm trying to use fcntl to implement filelocking. I was using flock until I discovered it only works between processes on the same machine. Now when I call fcntl with F_SETLKW, perl alarms (for adding a timeout) don't work as before. This would normally be ok, but ctrl-c doesn't reall...

How do I use WWW::Mechanize to check a radio box?

I am writing a Perl script to test certain parts of my webpage as I make changes to it. Using the WWW::Mechanize class, how can I select a radio box and submit a form? ...

Why doesn't my shell script work when I run it from Perl?

I have this command that I load (example.sh) works well in the unix command line. However, if I execute it in Perl using the system or ` syntax, it doesn't work. I am guessing certain settings like environment variables and other external sh files weren't loaded. Is there an example coding to ensure it will work? More Updates on codi...

How do I access and print a 3 or 4 dimensional hash in Perl?

Possible Duplicate: How can I iterate through nested arrays in Perl? I am trying to create a 3 - 4 dimensional hash by for ( $j=0;$j<$#temp_1;$j++) { for ( $i=0;$i<$#temp_2;$i++) { $var1{$mode}{$temp_1[$j]}{$temp_2[$i]}=$temp_3[$i]; } } $mode is predefined. also arrays @temp_1 , @temp_2 and @temp3 If I want ...

What's the difference between piping elements or specifying them as arguments in a Perl one-liner?

While learning Perl I am also learning Linux (Ubuntu), so it is kinda fire-hose sipping time around here. What is the difference between: find . -type f | perl -nle '... #aka yada yada' and perl -nle '... # same yada yada' `find . -type f` The first passes the file NAMES to Perl and the second passes the file CONTENTS it seems. ...

How can I grep and sort text files using Perl?

I have a simple log file which is very messy and I need it to be neat. The file contains log headers, but they are all jumbled up together. Therefore I need to sort the log files according to the log headers. There are no static number of lines - that means that there is no fixed number of lines for the each header of the text file. And ...

Why is using DBI's variable-binding causing a MySQL query to fail?

For some reason, using DBI's bind parameter feature for the below AES key is causing a query to fail to find any rows. use strict; use warnings; use DBI; my $dbh = DBI->connect('dbi:mysql:database=thedb;host=localhost'); my $aes_key = 'X`ku@wC_BI\SgY[S%/<iaB>&VXd5zDA+'; print length($aes_key), "\n"; my $test = $dbh->selectrow_hashref...

regex: separating procedure/function from PL/SQL code

I am writing Perl regex code to separate out PL/SQL procedure from the package. Each procedure starts with the PROCEDURE key word and ends with END, But the END is for BEGIN, IF, or LOOP. There may be many BEGIN|IF|LOOP. Below is the kind of input, I want to separate each procedure. How can I do this? PROCEDURE LOG_ECS_MSG( MD_CURR C...

How can I use Perl to delete a row in an Excel file?

I have to delete a line which contain zero in two columns. How do I do that? ...

How do I convert DateTime object to HTTP format?

I'm using the DateTime Perl module to get the time in a particular timezone. The result of the time is as follows 2010-09-24T02:18:52 How can I convert this to HTTP format before printing? ...

Why isn't my script processing all the elements in the array?

The following code is a test to test what I have already done with my new found knoledge of threads. #!/usr/bin/perl use strict; use warnings; use threads; use threads::shared; use URI; use URI::http; use File::Basename; use DBI; use HTML::Parser; use LWP::Simple; require LWP::UserAgent; my $ua = LWP::UserAgent->new; $ua->timeout(10); $...

How do you read CPAN changelogs?

Since discovering perlbrew, I'm a happy CPAN user. But what I have never figured out is how to read changelogs of modules. For example, when looking at the outdated ones with "r" in the CPAN shell, I'd like to easily inspect the changelog to decide whether to upgrade or not. Of course I can download the module, unpack it, and hunt aroun...

Why is HTML::TokeParser's get_trimmed_text changing the format of the date?

I'm using HTML::TokeParser to parse a website for a particular field. The field looks as follows 09/23/10 - 12:14 PM EDT However, when I print whatever is received, It displays, 2010-09-23 12:14:32.0 Why the inconsistency? Is it recognizing it as a time parameter and converting it to some internal format? If so how can I read...

How can I fetch a hash ref from array of hashes by one of its values?

I have a array of hashes, each hash containing same keys but values are unique. On the basis of particular value, I need to store hash ref. See the below example to understand it properly: my @aoaoh = ( { a => 1, b => 2 }, { a => 3, b => 4 }, { a => 101, b => 102 }, { a => 103, b => 104 }...

how to do client side sorting using querystring in hyperlink associated with the table header using Perl?

Hello everybody i hope everybody is doin well, Actually i have a table in which i fetch the data from sqlite database,i have done the paging and filtering for the grid using perl,now i need to do the sorting. The way in which i want to do is "MAKE THE TABLE HEADERS AS HYPERLINK AND WHENEVER I CLICK THEM THEN IT SHOULD SORT THE TABLE IN A...

What do I use to display CSV data as a chart?

I have a set of data stored in text files, which I have now via Perl put into a CSV file. The data in question now needs to be displayed in a chart. What suggestions do you have for doing this? XML was suggested, but XML can't put the data into a chart itself. Ideally what would happen is: the data would be decoded from the text file, ...

How does the `||` work in Perl?

How does the || works in Perl? I want to achieve c style || operation. @ARRAY=qw(one two THREE four); $i=0; if(($ARRAY[2] ne "three")||($ARRAY[2] ne "THREE")) #What's the problem with this { print ":::::$ARRAY[2]::::::\n"; } while(($ARRAY[$i] ne "three")||($ARRAY[$i] ne "THREE")) #This goes to infinite loop { pri...