perl

Perl: How to add an interrupt handler so one can control a code executed by mpirun via system()?

We use a cluster with Perceus (warewulf) software to do some computing. This software package has wwmpirun program (a Perl script) to prepare a hostfile and execute mpirun: # ... system("$mpirun -hostfile $tmp_hostfile -np $mpirun_np @ARGV"); # ... We use this script to run a math program (CODE) on several nodes, and CODE is normally ...

Is there a small Perl XML parser that can replace CGI.pm's HTML generation functions?

Is there any little (1-2 .pm's) parser based around XML::* and suitable for replacing CGI.pm's constructions like: foreach($xmlnodes) { print table( TR( td( $_) ) ); } with node2html($node,$rules)? I ain't going to fire up XSLT. ...

linux + find mechanism with Irregular Expression (find command) or perl

hi dear friends and good morning The following question may be complicated and critical for my systems I have 4 Linux machines with cluster My target is to find all kind of IP address (xxx.xxx.xxx.xxx) in every file in the linux system remark: need to scan each file in the linux system and verify if the file include IP address if ye...

How to find the mouse cursor index

Hi I wrote a script with the "undotext" widget, and I'm looking for a way to get the line index of the palce where the mouse cursor is standing. and similarly when the user has select part of the line. ...

Importing a require'd file as if it were a use statement

I am experiencing a problem with using a constant defined in a configuration file. This is my package: package myPackage; require "APIconfig.pl"; APIconfig::import(APIconfig); use constant SERVICE_URL => APIconfig::SERVICE_URL(); The configuration looks like this: package APIconfig; use constant SERVICE_URL => 'http://api.example.or...

How to verify which flags were read using Getopt::Long in Perl?

myscript.pl my $R; my $f1 = "f1.log"; my $f2 = "f2.log"; my $f3 = "f3.log"; sub checkflags { GetOptions('a=s' => \$f1, 'b=s' => \$f2, 'c=s' => \$f3, ); open $R, '>', $f1 or die "Cannot open file\n"; # Line a } All the flags are optional. If I call the script as perl myscript....

crawl a website for data at frequent intervals

Hi, I need to crawl a website and retrieve certain data that keeps getting updated every few minutes. How do i do this? ...

Identifying keywords of a (programming) language

Hi all, this is a follow up to my recent question ( Code for identifying programming language in a text file ). I'm really thankful for all the answers I got, it helped me very much. My code for this task is complete and it works fairly well - quick and reasonably accurate. The method i used is the following: i have a "learning" perl s...

Is there a name for this sort?

What is the name for the sort used in this answer? I Googled for "perfect insertion sort" but didn't find anything. Here is the code from that answer: #this is O(n) instead of O(n log n) or worse sub perfect_insert_sort { my $h = shift; my @k; for my $k (keys %$h) { $k[$h->{$k}{order}] = $k; } return @k; } ...

Perl function for negative integers using the 2's complement

I am trying to convert AD maxpwdAge (a 64-bit integer) into a number of days. According to Microsoft: Uses the IADs interface's Get method to retrieve the value of the domain's maxPwdAge attribute (line 5). Notice we use the Set keyword in VBScript to initialize the variable named objMaxPwdAge—the variable used to store the val...

Stopping Perl XS modules from silently falling back to pure-perl

It seems some (many?) modules on CPAN are partly implemented in C using XS, and can fall back to a pure-perl implementation if necessary. While this is smart, it can obviously hurt performance, and I would like to know it happens so I can fix the problem. Is there a general way of stopping or detecting this type of fallback? For an exa...

Pass zero in to Getopt::Std

Hi I am using Getopt::Std in a Perl script, and would like to pass in a zero as value. I am checking that values are set correctly using unless(). At the moment unless() is rejecting the value as being unset. Is there a way to get unless() to accept zero as a valid value (any non-negative integer is valid). This is probably perfeclty ...

Array Manipulation join with out split

@browser = ("NS", "IE", "Opera"); my $add_str = "Browser:"; $count = 0; foreach (@browser) { my $br = $_; $browser[$count] = "$add_str:$br"; $count++ ; } is there any other way to do this ? best way ? ...

how to select combobox item internet explorer for extjs application ?

First of all the code below works for my app for non ie browsers (i am using perl with selenium for extjs testing): http://seleniumexamples.com/blog/examples/select-an-option-from-an-extjs-combobox/ unfortunately the xpath library gives zero xpath count if i dare to add the visibility condition. The page content changes, so first i ha...

Writing a macro in Perl

open $FP, '>', $outfile or die $outfile." Cannot open file for writing\n"; I have this statement a lot of times in my code. I want to keep the format same for all of those statements, so that when something is changed, it is only changed at one place. In Perl, how should I go about resolving this situation? Should I use macros or func...

How to call script within subfolders

I have a script that I'm using to remove duplicate Calendar entries. The root mail folder contains folders with each folder being firstname_lastname, then beneath each other is /Calendar/#msgs/. As of now, I'm running script manually by going to the users' folder and starting the script /Users/Documents/duplicates/dups.pl . --killdups`...

Can I use Proc::Reliable on windows?

I'm using ActivePerl on a Win 7 box and I want to use the Proc::Reliable CPAN module. It downloaded and installed properly but when I tried to run the following code, it failed at run my $newProc = Proc::Reliable->new() $newProc->run("perl.exe -e print 'hello world'"); I tried a couple things, such as testing the status and trying to...

Perl Test::More and setting up test requirements.

With Test::More I often want to have a module that runs tests and has the ability to abort the callers test_plan. I have a series of tests that set up a plugin list for Catalyst::Test. I don't want to have to make my test check to see if they exist; instead, I want my script to abort if those plugins aren't present. I was trying to trac...

Whats wrong with this Perl replacement?

This is some very basic stuff, but I am not able to get what is wrong with it... test.pl my $file = "ooout.log"; print $file."\n"; my $file =~ s/\.log//g; print $file."\n"; output $ perl test.pl ooout.log $ I want to remove the .log at the end. I seem to be doing everything right according to this article. Where did I mes...

perl + Irregular Expression (VALID IP + ADD Valid Rule)

hi all the following syntax is part of perl script with Irregular Expression as we see the target of the following syntax is to get VALID IP address as 123.33.44.5 or 255.255.0.0 etc but how to change the following syntax if I want to valid also the IP: for example: 124.33.*.* (I want to valid also the * character as valid numb...