perl

Should I use Perl/Tk, Tcl::Tk or Tkx for a Perl GUI?

I really like Perl/Tk, but have come to the opinion that it's DOA. I think Tcl::Tk and Tkx are better solutions. Assume I drop Perl/Tk. Is the "most supported" route to go with Tcl::Tk (which hasn't been updated since 2007, and whose author seemingly cannot be reached), or Tkx? Are either of these actively used/supported? ...

Why is PowerShell (with Perl) removing double quotes in a simple print statement?

Hi, I am am a longtime Linux user but am new to Windows and PowerShell. I just installed Windows7 and Strawberry Perl 5 for the first time. I now want to do a simple command-line print with Windows PowerShell. It looks like Perl installed correctly: PS C:\Users\Me> perl -v This is perl, v5.10.0 built for MSWin32-x86-multi-thread Cop...

How can I set the file-read buffer size in Perl to optimize it for large files?

I understand that both Java and Perl try quite hard to find a one-size-fits all default buffer size when reading in files, but I find their choices to be increasingly antiquated, and am having a problem changing the default choice when it comes to Perl. In the case of Perl, which I believe uses 8K buffers by default, similar to Java's ...

Is it possible to make 'exec' use '$SHELL -c' instead of '/bin/sh -c' in Perl?

In Perl, is it possible to make 'exec', 'system', and 'qx' use a shell other than /bin/sh (without using a construct like 'exec "$SHELL -c ..."', and without recompiling perl)? EDIT: The motivation for this question is a bash script that does 'export -f foo' and then uses perl in a subshell to invoke the function directly via 'system "...

How can I fix a bootstrap version mismatch when loading Perl's threads module?

I am trying to use threads in Perl, but I get the following errors when I do require threads: ~ > perl -e 'require threads' threads object version 1.07 does not match bootstrap parameter 1.71 at /System/Library/Perl/5.8.8/darwin-thread-multi-2level/XSLoader.pm line 94. Compilation failed in require at -e line 1. I am using OS X 10.5.7...

How can I break up a string with multiple XML root elements in PowerShell?

Hi All, I am writing a PowerShell wrapper for an existing Perl script. The Perl script is fed a couple of parameters and goes off and configures all our HP iLO devices for us, and returns the results in an XML format. The problem is the result comes out as one big blob of multiple XML statements ie: $strResult = & "perl locfg.pl -s $il...

Why isn't my Perl format working?

All, I'm trying to get the code at the bottom to look like a check. Could you help me troubleshoot? Thanks, Frank format STDOUT = @<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @>>>>>>>>>>>>>>>>>>>>>>>>>>>>> $chkno $chkno $first $last ...

How can I perform an operation based on the previous read line in Perl?

Hi, I am still learning Perl scripting and need help in doing below task. Sample data: INV ,GOOD" 2405 INV ,BAD" 42 LOAD ,GOOD" 35588 LOAD ,BAD" 675 TRNS ,GOOD" 6 TRNS ,BAD" 122 I want to add the values under GOOD and BAD. GOOD, <sum of all good values> BAD, <sum of all bad values> Can anyone please suggest me code to read the f...

In Perl, how can I iterate over the Cartesian product of multiple sets?

Given x number of arrays, each with a possibly different number of elements, how can I iterate through all combinations where I select one item from each array? Example: [ ] [ ] [ ] foo cat 1 bar dog 2 baz 3 4 Returns [foo] [cat] [ 1 ] [foo] [cat] [ 2 ] ... [baz...

Is Perl guaranteed to return consistently-ordered hash keys?

Given something like foreach (keys %myHash) { ... do stuff ... } foreach (keys %myHash) { ... do more stuff ... } Is Perl guaranteed to iterate over the keys in a consistent order if the hash is not altered? ...

Is there a fast way to get the character index of a regex match?

I am creating a Perl script which will have to process the markup of millions of Wikipedia articles - so speed is an issue. One of the things I'm looking for are occurrences of templates, which always look like this: {{template}}. Because these can be complicated and nested, I need to find the start and end tags separately, and know th...

What is the correct usage of (nested | double | simple) quotes

Hi all, I'm sure this question may seem foolish to some of you, but I'm here to learn. Are these assumptions true for most of the languages ? EDIT : OK, let's assume I'm talking about Perl/Bash scripting. 'Single quotes' => No interpretation at all (e.g. '$' or any metacharacter will be considered as a character and will be printed ...

How can I store a list of references in Perl?

Hi, I would like to create a list of records. I can add one record just fine: my $records = [ { ID => 5342755, NAME => 'Me', } , ]; When I try to add another record, the other records disappear: $records = [ { ID => 1212121, } ]; What is the problem and how can I resolve this? ...

How can I implement a RESTful API in Perl?

I'm trying to implement a RESTful API in Perl. My current idea is to simply parse the path_info with a regex then dispatch the request to the appropirate subroutine which will then spit out the JSON, XML or even XHTML for the requested reource. For example to retrieve info about user 134 the RESTful cleint should find it at: http://mys...

How can I test whether a file has been opened for writing in Perl?

In my apps, I need to check whether a given file has been opened for writing for another process, and even this file has been opened my app just skip this file and no "die"-like things will happen here. more detailed description of my problem: there are two process involved. process A , which is the producer process, process B which i...

How do I add child elements to XML using Perl's XML::Twig?

I have the following XML file: <SOURCE_SERVER> <SERVER HOSTNAME="serv1"> <CIFS_SERVICE NETBIOSNAME="serv1"/> </SERVER> <SERVER HOSTNAME="serv2"> </SERVER> <SOURCE_SERVER> Now, I want to add child <CIFS_SERVICE NETBIOSNAME="serv2"/> to <SERVER HOSTNAME="serv2">. How do I do this using XML::Twig? ...

How do I validate a date in YYYY-MM-DD format in Perl?

Related/Possible duplicate: How can I validate dates in Perl? I have created a script where start and end date needs to be given by user while executing the script. The date format entered by user should be in YYYY-MM-DD format only. start_date = $ARGV[0]; end_date = $ARGV[1]; please advise. ...

How can I signal a forked child to terminate in Perl?

How can I make the same variable shared between the forked process? Or do I need to write to a file in the parent then read the value saved to the file in the child once the file exists? $something never appears to get set in this so it just loops in the sleep my $something = -1; &doit(); sub doit { my $pid = fork(); if ($pid == 0) ...

How do I install Image::Magick on Debian etch?

Hi all, I've been trying to install Image::Magick on Debian etch for a while without great success. I've got graphicsmagick-libmagick-dev-compat installed, but can't find the .deb for Perl's Image::Magick. And cpan -i Image::Magick gives me all sorts of compilation errors. Does anyone know the good combination of software so I can fina...

How can I remove a table from an HTML document?

I'm upgrading a set of web pages to a new system, and I want to strip out and replace the boilerplate at the top of each page, and replace it with new boilerplate. Fortunately, each page has a content table, and no tables before it. I want to do something like: $contents =~ s/^.*<table/$newHeader/ This only works for the first line of...