perl

How can I highlight text in Scintilla?

I am writing an editor using Scintilla. I am already using a lexer to do automatic syntax highlighting but now I'd like to mark search results. If I want to mark only one hit I can set the selection there but I'd like to mark (e.g. with yellow background) all the hits. I writing this in Perl but if you have suggestions in other languag...

What would be the best place to start learning AJAX (I have Perl as a backend)

I am currently developing a website using basic cgi to turn out pages. I would like the website to be changed to have a better (read dynamic) interface. What techniques (if not AJAX) and/or tutorials would you recommend to get me started? ...

How do I shrink an array in Perl?

How do I make an array shorter in Perl? I read some webpages indicating that I can assign: $#ARRAY = 42; I read that the use of $# is deprecated. I need a solution that will work for an array of arrays, too. This didn't work: $#$ARRAY[$i] = 42; ...

How do I convert a date/time to epoch time (aka unix time -- seconds since 1970) in Perl?

Given a date/time as an array of (year, month, day, hour, minute, second), how would you convert it to epoch time, i.e., the number of seconds since 1970-01-01 00:00:00 GMT? Bonus question: If given the date/time as a string, how would you first parse it into the (y,m,d,h,m,s) array? ...

In Perl, how do I create a hash whose keys come from a given array?

Let's say I have an array, and I know I'm going to be doing a lot of "Does the array contain X?" checks. The efficient way to do this is to turn that array into a hash, where the keys are the array's elements, and then you can just say if($hash{X}) { ... } Is there an easy way to do this array-to-hash conversion? Ideally, it should be v...

Is there any way to use a "constant" as hash key in Perl?

Is there any way to use a constant as a hash key? For example: use constant X => 1; my %x = (X => 'X'); The above code will create a hash with "X" as key and not 1 as key. Whereas, I want to use the value of constant X as key. ...

Obfuscation Puzzle: Can you figure out what this Perl function does?

sub foo {[$#{$_[!$||$|]}*@{$_[!!$_^!$_]}?@{$_[!$..!!$.]}[$_[@--@+]% @{$_[$==~/(?=)//!$`]}..$#{$_[$??!!$?:!$?]},($)?!$):!!$))..$_[$--$-]%@{ $_[$]/$]]}-(!!$++!$+)]:@{$_[!!$^^^!$^^]}]} update: I thought the word "puzzle" would imply this, but: I know what it does - I wrote it. If the puzzle doesn't interest you, please don't waste any ti...

Where can I get good answers to my Perl-related questions?

AFAIK one of the objectives of Stack Overflow is to make sure anyone can come here and find good answers to her Perl related questions. Certainly beginners would ask what is the best online source to learn Perl but others might just want to ask a question. Probably the friendliest place is the Monastery of Perl Monks. It is a web site w...

Useful Perl modules

What is the most important module you pull off of CPAN to add to a stock Perl install? One module only per response, please. Please explain why you think the module is best-of-breed ...

Which continuous integration framework for Perl?

What are the best continuous integration frameworks/projects for Perl and why? ...

What uses can you think of for Perl 6's junctions?

More information from the Perl 6 Wikipedia entry Junctions Perl 6 introduces the concept of junctions: values that are composites of other values.[24] In the earliest days of Perl 6's design, these were called "superpositions", by analogy to the concept in quantum physics of quantum superpositions — waveforms that can simultaneously oc...

What is a double underscore in Perl?

I'm trying to understand someone else's Perl code without knowing much Perl myself. I would appreciate your help. I've encountered a Perl function along these lines: MyFunction($arg1,$arg2__size,$arg3) Is there a meaning to the double-underscore syntax in $arg2, or is it just part of the name of the second argument? ...

How can I install CPAN modules locally without root access (DynaLoader.pm line 229 error)?

Doesn't work with other modules, but to give an example. I installed Text::CSV_XS with a CPAN setting: 'makepl_arg' => q[PREFIX=~/lib], When I try running a test.pl script: $ perl test.pl #!/usr/bin/perl use lib "/homes/foobar/lib/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi"; use Text::CSV_XS; print "test"; I get ...

Is Perl still a viable language for web development?

I am currently in the process of designing a database-driven website to manage various personal data and some business data. This is primarily a personal app, however it will be used by a few clients to retrieve and update information. Is Perl still a viable language to code a website with the newer .NET options, Python, etc. available...

How can I make a batch file to act like a simple grep using Perl?

I already know the obvious answer to this question: "just download <insert favorite windows grep or grep-like tool here>". However, I work in an environment with strict controls by the local IT staff as to what we're allowed to have on our computers. Suffice it to say: I have access to Perl on Windows XP. Here's a quick Perl script I ...

How to find the amount of physical memory occupied by a hash in Perl?

I have a Perl script where I maintain a very simple cache using a hash table. I would like to clear the hash once it occupies more than n bytes, to avoid Perl (32-bit) running out of memory and crashing. I can do a check on the number of keys-value pairs: if (scalar keys %cache > $maxSize) { %cache = (); } But is it possible to c...

How do you capture stderr, stdout, and the exit code all at once, in Perl?

Is it possible to run an external process from Perl, capture its stderr, stdout AND the process exit code? I seem to be able to do combinations of these, e.g. use backticks to get stdout, IPC::Open3 to capture outputs, and system() to get exit codes. How do you capture stderr, stdout, and the exit code all at once? ...

Is there a Perl solution for lazy lists this side of Perl 6?

Has anybody found a good solution for lazily-evaluated lists in Perl? I've tried a number of ways to turn something like for my $item ( map { ... } @list ) { } into a lazy evaluation--by tie-ing @list, for example. I'm trying to avoid breaking down and writing a source filter to do it, because they mess with your ability to debug t...

How can I install ExtUtils::PkgConfig in Perl on Windows?

I've tried cpan and cpanp shell and I keep getting: ExtUtils::PkgConfig requires the pkg-config utility, but it doesn't seem to be in your PATH. Is it correctly installed? What is the pkg-config utility and how do I install it? Updates: OS: Windows This module is a prerequisite for the File::Extractor module ...

What is your latest useful Perl one-liner (or a pipe involving Perl)?

The one-liner should: solve a real-world problem not be extensively cryptic (should be easy to understand and reproduce) be worth the time it takes to write it (should not be too clever) I'm looking for practical tips and tricks (complementary examples for perldoc perlrun). ...