perl

How can I read the lines of a file into an array in Perl?

I have a file named test.txt that is like this: Test Foo Bar But I want to put each line in a array and print the lines like this: line1 line2 line3 But how can I do this? ...

How do I access a SQL Server database from a Perl script in Linux?

I have a Perl script on a Linux (Ubuntu 8.10) machine and I need to write data to a SQL Server Database. I've been trying to use the DBD::ODBC module but I can't get it to connect. Where can I get a free/open source driver to use to use for the ODBC connection or is there another way to do this from Perl on Linux? ...

Are @{$list_ref} and @$list_ref equivalent in Perl?

I am new to Perl and am curious whether @{$list_ref} and @$list_ref are perfectly equivalent. They seem to be interchangeable, but I am nervous that there is something subtle going on that I may be missing. ...

How can I replace all 'die's with 'confess' in a Perl application?

I'm working in a large Perl application and would like to get stack traces every time 'die' is called. I'm aware of the Carp module, but I would prefer not to search/replace every instance of 'die' with 'confess'. In addition, I would like full stack traces for errors in Perl modules or the Perl interpreter itself, and obviously I can't ...

What's the modern way of declaring which version of Perl to use?

When it come to saying what version of Perl we need for our scripts, we've got options, oh, brother, we've got options: use 5.010; use 5.010_001; use 5.10.0; use v5.10; use v5.10.0; All seem to work. perlcritic complains about all but the first two. (It's unfortunate that the v strings seem to have such flaws, since Perl 6 expects y...

How do I get HTTP::Proxy to log filter information?

I'm having some trouble getting filters working with HTTP::Proxy and I just can't seem to figure out what I should add to the logmask() function to get that information. I've got a log file, that part is fine, logging is happening, but no information about filters, although they're implemented and (sometimes) working. I've tried log...

How do I install a module and its dependencies in ActivePerl on Windows?

I want to send emails using gmail's smtp servers and perl. I am trying to install Email::Send::Gmail, but it is not clear to me what are the steps to install it. It seems that it depends on other modules that I do not have installed. ...

Using Perl's Template.pm, how can I select a random element from an array and output it?

Suppose I have the following in my template: [%- pages = [ 'one', 'two', 'three' ] -%] <p>Go to page [%- ... -%]</p> Assuming EVAL_PERL is not set (i.e., I cannot use a [%- PERL -%] block), what do I need to put inside the [%- ... -%] above so as to get the following output? <p>Go to page "a randomly picked element of pages"</p> ...

How can I see raw bytes stored in a MySQL column?

I have a MySQL table properly set to the UTF-8 character set. I suspect some data inserted into one of my columns has been double encoded. I am expecting to see a non-breaking space character (UTF-8 0xC2A0), but what I get when selecting this column out of this table is four octets (0xC3A2 0xC2A0). That's what I would expect to see if...

How can I quickly check if Linux `unzip` is installed using Perl?

How can I quickly check if Linux unzip is installed using Perl? ...

How can I add time information to STDERR output in Perl?

Is there an easy way to time tag errors going to stderr? In order to troubleshoot problems, I need to know when an error occurred. Example: Dec 10 12:00:00 Can't call method "str" on an undefined value Thanks! ...

Registering multiple Perl sub references for a C library in XS

Both perlcall (in the "Strategies for storing Callback Context Information" section) and Extending and Embedding Perl (in the "Callback" section) lists 3 different ways to handle calling Perl sub routines from XS/C: Immediately: XS calls Deferred: saving the sub ref as an SV* for later Multiple: save n sub refs for later The example...

What are some alternatives to PersistentPerl or SpeedyCGI?

I like PersistentPerl quite a bit for both web and command-line use. The only problem is it keeps me tied down to Perl 5.8.x, as it's apparently no longer maintained. I'm aware of mod_perl and FastCGI, but these don't appear to have CLI functionality (correct me if I'm wrong!). So is there a suitable replacement for PersistentPerl? ...

How can I obfuscate my Perl script to make it difficult to reverse engineer?

I've developed a Perl script that has a confidential business logic. I have to give this script to another Perl coder to test it in his environment. He will definitely try to extract the logic in my program. So I want to make my script impossible, or at least very very hard, to understand. I've tried a few sites like liraz, but they ...

Which perl can I use from the Windows command line?

Hi all: Can anyone recommend me a Perl interpreter that can run on Windows command line to read LCOV files (and generate a report of some sort)? I looked at genhtml, and it seems to need a lot of setup and must run in the bash shell environment, which doesn't sound good for Windows command line. Thanks. ...

How can I reset a file handle receiving standard input in Perl?

When I issue a Perl script some standard input, e.g. $ awk '{print $1"\t"$2}' foo.txt | myScript.pl I have a script which contains a bug. It reads the first line of standard input, gets something from that first line, and then only parses lines 2 through n of standard input on subsequent read: open (FH, "< $input") or die $?; my $fir...

What do people mean when they say “Perl is very good at parsing”?

What do people mean when they say "Perl is very good at parsing"? How is Perl any better or more powerful than other scripting languages such as Python or Ruby? ...

How can I develop an iPhone application in Perl?

Could someone provide a good link to book about how to develop iPhone application with the Perl programming language? ...

Intelligent RegEx in Perl?

Background Consider the following input: <Foo Bar="bar" Baz="1" Bax="bax" > After processing, I need it to look like the following: <Foo Bar="bar" Baz="1" Bax="bax" CustomAttribute="TRUE" > Implementation This is all I need to do for no more than 5 files, so using anything other than a regular expr...

How can I limit the size of HTTP POST requests in mod_perl?

Hi, I'm working on a page which accepts file uploads. In theory, I can detect when the file they're sending me is too big (by looking at the Content-Length of their response), and refuse to accept the upload, returning an HTTP 413 "Request Entity Too Large" error. However, it seems that simply doing that is not enough -- Firefox, at le...