perl

What other languages have features and/or libraries similar to Perl's format?

I may be in the minority here, but I very much enjoy Perl's formats. I especially like being able to wrap a long piece of text within a column ("~~ ^<<<<<<<<<<<<<<<<" type stuff). Are there any other programming languages that have similar features, or libraries that implement similar features? I am especially interested in any libra...

How can I call a DLL from a scripting language?

I have a third-party product, a terminal emulator, which provides a DLL that can be linked to a C program to basically automate the driving of this product (send keystrokes, detect what's on the screen and so forth). I want to drive it from a scripting language (I'm comfortable with Python and slightly less so with Perl) so that we don'...

DBI's column_info vs. pgAdminIII on quoted identifiers

I have a table in my pgsql database with columns named "type", "desc", and "start". When I call $dbh->column_info, only "desc" comes back quoted, whereas in pgAdmin3 all three of them are quoted. Is one of them wrong? ...

What's the best practice for changing working directories inside scripts?

Do you think changing directories inside bash or Perl scripts is acceptable? Or should one avoid doing this at all costs? What is the best practice for this issue? ...

How can I determine CPAN dependencies before I deploy a Perl project?

Does anyone have any suggestions for a good approach to finding all the CPAN dependencies that might have arisen in a bespoke development project. As tends to be the case your local development environment rarely matches your live one and as you build more and more projects you tend to build up a local library of installed modules. These...

What does $#array mean in Perl?

I'm looking at the following code snippet: my @ret = <someMethod> return (undef) if( $DB_ERROR ); return (undef) unless ($#ret >= 0); Does $# just give you a count of elements in a array? ...

What is the easiest or most effective way to convert month's abbreviation to a number in Perl? (ie "jan" to 1)

If I import a library to use a method, would it be worth it? Does importing take up a lot of memory? ...

Net::SSLeay post_https compilation error: Too many arguments

I'm interfacing with a payment gateway and not having any luck with Net::SSLeay and its post_https subroutine. The payment gateway has issued me a client certificate that must be used for authentication. The Net::SSLeay perldoc has the following example: ($page, $response, %reply_headers) = post_https('www.bacus.pt', 443, '/f...

How can I validate large numbers of files with search and replace?

I am currently validating a client's HTML Source and I am getting a lot of validation errors for images and input files which do not have the Omittag. I would do it manually but this client literally has thousands of files, with a lot of instances where the is not . This client has validated some img tags (for whatever reason). Just w...

Is it safe to read regular expressions from a file?

Assuming a Perl script that allows users to specify several text filter expressions in a config file, is there a safe way to let them enter regular expressions as well, without the possibility of unintended side effects or code execution? Without actually parsing the regexes and checking them for problematic constructs, that is. There wo...

How do I make a complex query with Perl's Net::LDAP?

Hi. I'm having trouble running a complex query against our company LDAP server. I'm using the following Perl script: use Data::Dumper; use Net::LDAP; die "Can't connect to LDAP-Server: $@\n" unless $ldap = Net::LDAP->new( 'xLDAPx' ); foreach my $filter ( 'ou=Personal', 'ou=BAR', 'ou=Personal,ou=BAR', 'ou=Personal,ou=FOO,o=FOO,d...

How does MediaWiki compose the image paths?

I have a Perl app. that parses MediaWiki SQL tables and displays data from multiple wiki pages. I need to be able to re-create the absolute image path to display the images, eg: [.../f/fc/Herbs.jpg/300px-Herbs.jpg] From MediaWiki Manual:Image_Authorisation: "the [image] path can be calculated easily from the file name and..." How is th...

Stateful tail (only shows the new lines from the last execution)

I want to be able to see how many lines were added to a file since the last quering without reading the whole file again. Something like : ptail my_file | fgrep "[ERROR]" | wc -l A solution in simple Perl would be prefered, since I don't have an easy access to a compiler. ...

What's the best way of executing tasks in parallel in Ksh and Perl?

I have this large C++ project that I need to build on a platform that does not have a parallel make (like make -j on Linux). The server has 6 CPU's and I want to do a parallel build manually. I can generate a task list like this for about 300 object files. I use the Makefile for the dependency checks and incremental build: make -f Mak...

Is there a simple way to do bulk file text substitution in place?

First of all, I'm a Perl newbie, so please be gentle =) I've been trying to code a Perl script to substitute some text on all source files of my project. I'm in need of something like: perl -p -i.bak -e "s/thisgoesout/thisgoesin/gi" *.{cs,aspx,ascx} But that parses all the files of a directory recursively. I just started a script: ...

What is the best way to parse HTML from a Rich Text Editor in Perl?

Is there a Perl module out there that can take bad HTML (such as what is copied from Microsoft Word) and parse it into nicely formatted HTML? I have looked at HTML::Tidy, but it has gotten horrible reviews on CPAN. We have a custom legacy module that's basically a wrapper for the command line version of tidy (which seems to be pretty m...

How can I determine if a URL redirects?

If I have a URL (eg. http://www.foo.com/alink.pl?page=2), I want to determine if I am being redirected to another link. I'd also like to know the final URL (eg. http://www.foo.com/other_link.pl). Finally, I want to be able to do this in Perl and Groovy. ...

How can I check if I have a Perl module before using it?

I have some pretty simple perl code which relies on Term::ReadKey to get the terminal width; My NetBSD build is missing this module, and I want to default to 80 when the module is missing. The odd thing is, I can't figure out how to conditionally use a module, knowing ahead of time whether it is present. This code would just quit saying...

How can I use a new Perl module without install permissions?

Here is my situation: I know almost nothing about Perl but it is the only language available on a porting machine. I only have permissions to write in my local work area and not the Perl install location. I need to use the Parallel::ForkManager Perl module from CPAN How do I use this Parallel::ForkManager without doing a central instal...

Have you used the Perl 5.10 backtracking control verbs in your regexes yet?

Have you used the Perl 5.10 backtracking control verbs in your regexes yet? And what problems did they help you accomplish? Just as background: I have done some fiddling, but I can't get any really useful results. As a comparison, when I started getting what the (?> grouping did, it started showing up more in my regexes. I liked the...