perl

How can I merge several hashes into one hash in Perl?

In Perl, how do I get this: $VAR1 = { '999' => { '998' => [ '908', '906', '0', '998', '907' ] } }; $VAR1 = { '999' => { '991' => [ '913', '920', '918', '998', '916', '919', '917', '915', '912', '914' ] } }; $VAR1 = { '999' => { '996' => [] } }; $VAR1 = { '999' => { '995' => [] } }; $VAR1 = { '999' => { '994' => [] } }; $VAR1 = { '9...

What's the difference in delayed evaluation of code in subroutines for Perl's 5.8 vs. 5.10 and 5.12?

This bit of code behaves differently under Perl 5.8 than it does under Perl 5.12: my $badcode = sub { 1 / 0 }; print "Made it past the bad code.\n"; When I run it under 5.8, I get an error even though I never execute the division: [brock@chase tmp]$ /usr/bin/perl -v This is perl, v5.8.8 built for i486-linux-gnu-thread-multi [broc...

POD multilanguage documentation

Is there any way to write multilanguage documentation using POD? If no, what should I write it in (I already have POD documentation in English, so I will want to convert it and then translate)? ...

How can I get a working Data::Alias in Perl 5.12?

I like Data::Alias. It seems to be broken in 5.12. Can it be fixed? Will it be fixed soon? Is there any nice alternative? ...

How can I authenticate when using the Bugzilla Perl API in a script?

Working from the Bugzilla API, I've written a quick Perl script to clone a Bugzilla Product (recreating all the Components under their new Product). The Bugzilla Perl API is quite easy to use from the command line. I could have just worked on the database directly, but I wanted a longer-term solution. Another option was the webservice, b...

How do I perform multiple replacements with Perl?

I have Perl code: my $s = "The+quick+brown+fox+jumps+over+the+lazy+dog+that+is+my+dog"; I want to replace every + with space and dog with cat. I have this regular expression: $s =~ s/\+(.*)dog/ ${1}cat/g; But, it only matches the first occurrence of + and last dog. ...

Executing Powershell from Perl

Hi, I have a bunch of Powershell scripts which I need to run from Perl. I have the following code but for some reason the Powershell scripts dont get invoked. I have tried both the backtick and the system command $path = "C:/Users/PSScript.ps1"; $pwspath = "c:/windows/system32/windowspowershell/v1.0/powershell.exe"; $output = `$pwspat...

Selenium Testing

Hi I want to get a bunch of dom-objects with xpath and loop through those to check if they contains a specified text, is this possible in the Selenium IDE or rc? Perl is my prefered language XPath would be something like xpath=//tbody[@class='table-data']/tr/td/div[@class='table-item'] This would return all row items in the table, but...

Perl: print back to beginning of line

Okay, so what I'm trying to do is print out a percentage complete to my command line, now, I would like this to simply 'update' the number shown on the screen. So somehow go back to the beginning of the line and change it. For example the windows relog.exe command-line utility (which can convert a .blg file to a .csv file) does this. If...

What's a good Perl OO interface for creating and sending email?

I'm looking for a simple (OO?) approach to email creation and sending. Something like $e = Email->new(to => "test <[email protected]>", from => "from <[email protected]>"); $e->plain_text($plain_version); $e->html($html_version); $e->attach_file($some_file_object); I've found Email::MIME::CreateHTML, which looks great in almost every way, ex...

Can I customize the indentation of ternary operators in emacs' cperl-mode?

In emacs cperl-mode, ternary operators are not treated specially. If you break them over multiple lines, cperl-mode simply indents each line the same way it indents any continued statement, like this: $result = ($foo == $bar) ? 'result1' : ($foo == $baz) ? 'result2' : ($foo == $qux) ? 'result3' : ($foo == $quu...

How to use one script for diff and diff3 in Subversion?

I have a perl script that determines what external diff to use depending on the file's content. I would like to use it determine external diff3 also. Which is the best method to know how my script is being called? I was planning to catch the last three parameters, and verify if they are all files, to use the diff3 options, but I'm hopi...

Perl - Calling subclass constructor from superclass (OO)

This may turn out to be an embarrassingly stupid question, but better than potentially creating embarrassingly stupid code. :-) This is an OO design question, really. Let's say I have an object class 'Foos' that represents a set of dynamic configuration elements, which are obtained by querying a command on disk, 'mycrazyfoos -getconf...

What is dmake actually doing when installing a new module?

I just mangaged to install the perl/Tk module after much struggle. I realise I don't understand what dmake or make etc is actually doing. I am using strawberry perl installed at C:\strawberry. Fisrt I unpacked the module to another directory and ran perl makefile.pl which worked fine. Then I tried dmake which did not work. I guess that...

Why do I get strange output from Perl using SQL?

Here is my Perl code: foreach my $line (@tmp_field_validation) { chomp $line; my ($cycle_code,$cycle_month,$cycle_year)= split /\s*\|\s*/, $line; $cycle_code=~ s/^\s*(.*)\s*$/$1/; $cycle_month=~ s/^\s*(.*)\s*$/$1/; $cycle_year=~ s/^\s*(.*)\s*$/$1/; print "$line\n"; print "$cycle_c...

mod_perl memory leak

Hello, I recently discovered that one of our sites has a memory leak in it, it's very strange because it happened all of the sudden. I've used GTop to measure the memory size per process and it tells me that the real value is somewhere around 65 MB (on the server) per request and and additional 5 MB shared. I tried preloading the modul...

perl split on empty file

I have basically the following perl I'm working with: open I,$coupon_file or die "Error: File $coupon_file will not Open: $! \n"; while (<I>) { $lctr++; chomp; my @line = split/,/; if (!@line) { print E "Error: $coupon_file is empty!\n\n"; $processFile = 0; last; } } I'm having trouble determining what the split/,/ func...

In Perl, given two IO::Socket's how do I connect 1st socket's input to 2nd's output and vice versa?

Suppose I have made two connections in Perl with the help of IO::Socket. The first has socket $s1 and the second has socket $s2. Any ideas how can I connect them together so that whatever gets received from $s1 got sent to $s2 and whatever gets received from $s2 got sent to $s1? I can't understand how to do it. I don't know how to conn...

SQLite how to use perl DBI to return SQLite database waiting status?

Hi! I used BEGIN EXCLUSIVE for my write transaction so that the other users connect to the database at the same time will have to wait. My question is "Is there a way to track how long the script has been waiting before timeout"? I would like to return either a "database locked" or "sqlite busy" message to a variable in my script and ex...

User input in Perl with IO::Socket

I am trying to make a perl program which allows a user to input the host and the port number of a foreign host to connect to using IO::Socket. It allows me to run the program and input a host and a port but it never connects and says "Could not connect to [host] at c:\users\USER\Documents\code\perl\sql.pl line 18, line 2." What am i doi...