perl

XPath loop with Selenium and perl

Hi, I'm trying to extract all name values in input fields using selenium and perl. Part of the value, enough to identify it, is known, the rest is unknown: This xpath works in finding all relevant matches: //tr/td//input[contains(@name,'partofname')] So, in perl: my $xpath = qq(//tr/td//input[contains(\@name,'partofname')]); my $c...

Problem with Mercurial and third-party hg-login script

I'm trying to setup mercurial using the HgLogin I have the following problem system. I done everything that is needed but when I tried to login to my repository I receive this answer: remote: /home/mercurial/hg-login: line 1: use: command not found : command not foundrial/hg-login: line 1: : command not foundrial/hg-login: line 2: remo...

How do I use Expect to connect with SSH?

In my program I use Expect to run ssh. My program is $argument="[email protected]"; $exp->spawn("ssh $argument") or die "Cannot spawn ssh to ip $ssh_ip_address\n"; But even if it is not able to spawn ssh it is not printing Cannot spawn ssh to ip $ssh_ip_address. Can you please help me understand why it does give the error message? ...

Installation of perl DBD-MySQL Package on solaris 10 without the presence of C compiler

I compile the perl DBI package on solaris 10 say SERVER1 with say perl 5.8.10 installed on it and create DBI. Now I copy the above DBI.so and the DBI.pm files to another solaris SERVER2 machine with the same hardware and the same version of perl. Can I be sure that the DBI package will run smoothly and I will not get any run-time error...

Perl equivalent of PHP's escapeshellarg

To escape the string to be used as shell argument we use the function escapeshellarg() in PHP. Does Perl have an equivalent function ? ...

printf how to do floating points with leading zeros.

I know how to do X amount of leading zeros, and I know how to do X amount of decimal points. But, how do I do them both? I am looking to have 4 leading zeros to a decimal precision of 2: 0000.00. Therefore 43.4 would be 0043.40 ...

Strange behaviour of sort

I have this piece of script : #!/usr/bin/perl use strict; use warnings; use Data::Dumper; my @arr = ( { name => 'foo', value => 123, }, { name => 'bar', value => 'nan', }, { name => 'foobar', value => 456, }, ); @arr = sort {$a->{value} <=> $b->{value} } @arr; ...

Is locale setting global in perl?

I'm debugging a perl script which looks like this (simplified): #!/usr/bin/perl use strict; use warnings; use Evil::Module; printf "%.3f\n", 0.1; This script outputs 0,100 (note , instead of .). If I comment out the use Evil::Module statement, the output will be 0.100. I believe that this is related to locale setting in the mod...

What is the best way to determine if a scalar holds a filehandle?

I am trying to determine if a given scalar holds a filehandle. It could have been passed to me from a bareword filehandle (i.e. \*FH), a lexical filehandle, an IO::Handle, an IO::File, etc. So far I the only thing that seem to be consistent amongst the various flavors is that they all have a reftype of "GLOB". ...

Perl - remove carriage return and append next line

What if I have a record in a otherwise good file that had a carriage return in it. Ex: 1,2,3,4,5 ^M ,6,7,8,9,10 and I wanted to make it 1,2,3,4,5,6,7,8,9,10 ...

Interleaving sparse sorted arrays

I've got a set of lists of events. The events always happen in a given order, but not every event always happens. Here's an example input: [[ do, re, fa, ti ], [ do, re, mi ], [ do, la, ti, za ], [ mi, fa ], [ re, so, za ]] The input values don't have any inherent order. They're actually messages like "creating symlinks" and "r...

Perl creating SSL socket fails with "Bad hostname" after 1020 Sockets

Could use some help. I am utterly stuck, been trying to fix this one for a whole week. I have a perl script that acts as an email server. After it sets up 1,020 SSL Sockets, it starts failing every time when for every socket before that works fine. Any suggestions? Why is it saying bad hostname? The error I get is Setting up user 1014.....

Using StartTLS with Perl-LDAP

Hi, I'm trying to use Net::LDAP in Perl to do LDAPS authentication against my Server 2008 Active Directory and I'm having a hard time getting server verification to work. It works if in start_tls I useverify=> 'none', but this is not so great. When I use verify => 'require' (which is preferable), I get this error: SSL connect att...

Writing C# equivalent of perl code to send and receive through UDP socket?

I want to write code in C# similar to following code in perl. What the code does is sends a message through UDP socket and requests for a TCP Port. The code in perl is as below: # Get a UDP connection to port $proto = getprotobyname('udp'); no strict 'refs'; $udpS = "UDP Socket"; if ( !socket($udpS, AF_INET, SOCK_DGRAM, $proto)...

Perl's foreach and changing the looping variable

I am writing a script in Perl and have a question about Perl's foreach construct. It appears that if you change one of the loop variables it changes in the actual array. Is this in fact the case, or have I done something completely wrong? I want to change a string like abc.abc#a to abc_abc_a (underscores for non alpha-numeric characte...

Need more examples on how to use Spreadsheet::ParseExcel

I have been using the Spreadsheet::ParseExcel to list the contents of spreadsheet. I've seen several examples on how to dump the entire spreadsheet. I really would like to see how to use this script more selectively. The example below from IBM basically dumps the content of all cells that have data. #!/usr/bin/perl -w use strict;...

Convert simple code from Perl to PHP (issue)

Possible Duplicate: Convert a Perl code to PHP Hello all, I don't know much in Perl and I'm having problems converting a simple code from Perl to PHP: here is the code: pack("SSA12AC4L", $id, $loc, $name, 'ar', $get->getIP), time))...

In Perl, how do I process multiple lines.

Say, I have a file that has the following lines with a "TIMESTAMP" "NAME": 10:00:00 Bob 11:00:00 Tom 11:00:20 Fred 11:00:40 George 12:00:00 Bill I want to read this file, group the names that occur in each hour on a single line, then write the revised lines to a file, for example. 10:00:00 Bob 11:00:00 Tom, Fred, George 12:00:00 ...

What kind of things can be done using Perl but cannot be done using Bash?

I'm new in using scripting language. I come across 2 scripting languages called Perl and Bash shell script. I would like to know what kind of things can be done using Perl script but cannot be done using Bash shell script? Thanks. ...

Convert a Perl function to PHP

Hello, I want to convert the perl function below to PHP function, if someone could help a little bit I'd appreaciate it: sub encode32 { $_=shift; my($l,$e); $_=unpack('B*',$_); s/(.....)/000$1/g; $l=length; if($l & 7) { $e=substr($_,$l & ~7); $_=substr($_,0,$l & ~7); $_.="000$e" . '0' ...