perl

Comparison of Regex flavours

I wonder if there is a comparison between the features of various regex metacharacters in various implementations. The sort of thing I am looking for is a table like Language Perl sed grouping ( ) \( \) Languages I am interested in are Perl, Sed Java Javascript ...

Which Blowfish algorithm is the most 'correct'?

I'm running Windows Server 2k8 (maybe that's half the problem?) Anyway, I'm getting different values out of different Blowfish modules in various languages. Is there one which can be relied upon as the standard? For the following examples, assume the key is password and the plaintext 12345678. a. The Online Encrypt Tool with Algorithm ...

How do I use perlbrew to manage perl installations aimed at web applications?

I have been using perlbrew to manage multiple versions of perl on a Linux Fedora notebook. I have used it with great benefit to run command-line scripts mostly using App::cmd. I now want to move to running web applications written using CGI::Application using different perls installed in my $HOME. I am familiar with running Perl web ap...

Escape whitespace when using backticks.

I've had a search around, and from my perspective using backticks is the only way I can solve this problem. I'm trying to call the mdls command from Perl for each file in a directory to find it's last accessed time. The issue I'm having is that in the file names I have from find I have unescaped spaces which bash obviously doesn't like. ...

How can I use File::Find in Perl?

I'm a bit confused from File::Find documentation... what is the equivalent to $ find my_dir -maxdepth 2 -name "*.txt"? ...

Perl: Is quotemeta for regular expressions only? Is it safe for file names?

While answering this question regarding safe escaping of filename with spaces (and potentially other characters), one of the answers said to use Perl's built-in quotemeta function. The documentation of quotemeta states: quotemeta (and \Q ... \E ) are useful when interpolating strings into regular expressions, because by default an in...

How can I handle a dialog box raised by a program I start from Perl?

I have a Perl script that calls another application I don't have control over. I use the system() to call this application. On occasion, this application generates an unhandled exception and puts up an exception dialog box that needs to be attended to. Since this is an unattended Perl script, I would like to detect this situation and han...

How can I manipulate a local database with Perl?

I'm a Perl programmer with some nice scripts that go fetch HTTP pages (from a text file-list of URLs) with cURL and save them to a folder. However, the number of pages to get is in the tens of millions. Sometimes the script fails on number 170,000 and I have to start the script again manually. It automatically reads the URL and sees if ...

Parsing nested/related-value strings in functional style.

$tasks->{t1}{cmdline} = "convert -f %FONT% %1%"; $tasks->{t1}{report} = "Launched as %CMD% by %USER%"; $tid = 't1'; foreach my $parm (keys %{$tasks->{$tid}}) { $tasks->{$tid}{$parm}=~s/%FONT%/$tasks->{$tid}{font}/g; # may evaluate if $parm == 'cmdline'; $tasks->{$tid}{$parm}=~s/%CMD%/$tasks->{$tid}{cmdline}/g; } The code is bad...

Why doesn't Perl find my script when I use the -I switch?

I have googled a way to do this kind of thing. I use this shell command: perl -I/p2 maxconnect4.p1 arg1 arg2 arg3 arg4 My pl files and pm files are all in "p2" directory. However, it gives me an error: Can't open perl script "maxconnect4.pl": No such file or directory Can anyone explain why? ...

How can I edit file metadata in OS X?

Does anyone know if it is possible to directly edit file metadata on OS X. Specifically in perl. The parameter I'm specifically trying to change is kMDItemFSLabel (The color of the file). I've had a search around and I can't seem to find a way to do this without using a module such as Mac::Glue or an external application (Finder). ...

Which Perl modules for good for data munging?

Nine years ago when I started to parsing HTML and free text with Perl I read the classic Data Munging with Perl. Does someone know if David is planning to update the book or if there are similar books or web pages where the new parsing modules like XML-Twig, Regexp-Grammars, etc, are explained? I assume that in the last nine years some ...

How do I capture the output of a Perl program so I can mail it?

I want to send the output of a Perl file in the body of the mail. Can some one let me know how I can capture the output of the Perl which prints something on the cmd to a variable? I am running a Perl script from a command prompt and I get the output on the command prompt itself. I want to print the output on the command prompt to the b...

How do I run a script on the 1st working day of every month?

I have to run a script on the 1st working day of every month. Please suggest how I can do it in Perl. Lets say if its national holiday in that country, the script should run on 2nd working day. I have one binary which give me output of previous working day if its holiday for specific country. ...

How can I configure "Checking for Errors" for DNS Lookup using Perl?

I have a script which allows me to lookup for a hostname after inputting an IP address which would be forwarded to a DNS server. However even though everything works fine, the program can't seem to print out the errors that I want example if the DNS cannot be found. The Codes: #!/usr/bin/perl use IO::Socket; use warnings; use strict;...

Why does perl2exe complain about "Unresolved symbol: Perl_Gthr_key_ptr"?

In Perl, what does this error mean? Unresolved symbol: Perl_Gthr_key_ptr I am getting this error while converting a Perl file to binary using perl2exe on a HP-UX PA-RISC machine. /usr/lib/dld.sl: Unresolved symbol: Perl_Gthr_key_ptr (code) from /tmp/p2xtmp-9979/Cwd.sl IOT trap (core dumped) ...

Is there an elegant way to store an ontology graph and the definitions/data associated with nodes?

I have written a simple module to store and manipulate an ontology which is provided in a flat file using Perl. For this, I use the Graph module which is excellent. One issue I am having to deal with is how to store the textual definitions for the vertexes in the ontology. Each term has a small text description which I want to store an...

How do I decide if a variable is numeric in Perl?

Possible Duplicate: How do I tell if a variable has a numeric value in Perl? I want to decide if a variable (value parsed from a string) is a number or not. How can I do that? Well, I guess /^[0-9]+$/ would work, but is there a more elegant version? ...

Why is `print (52-80)*42` different than `print 42*(52-80)` in Perl?

PERL:: What is: (52-80)*42 42*(52-80)? Ans: 1) -28 2) -1176. Why? Have fun explaining/justifying this please! #!/usr/bin/perl use strict; print 42*(52-80) , "\n"; print ((52-80)*42) , "\n"; print (52-80)*42 , "\n"; print "\n"; my $i=(52-80)*42; print $i, "\n"; Output: > -1176 > -1176-28 > -1176 ...

How can I completely delete a package in Perl?

How do you completely delete a package in Perl? This means not only the package variables, but also any magic tables that Perl updates to handle inheritance changes and other things. This simple test: use warnings; use strict; use Test::LeakTrace; use Symbol 'delete_package'; leaktrace { package test; our $x = 1; package ma...