perl

What happens in these Perl use lines?

I don't understand what happens here : use PAR { file => 'foo.par', fallback => 1 }; I think that's an anonymous hash. How is a module using it from the use line? Can you shed some light? EDIT: I'm not interested in the PAR module. I'm just interested in how that works behind the curtain. How can I configure my modules like that? ...

What are the basic knowledge requirement for a Perl developer?

What are the concepts that must be known by a new Perl developer for searching a job. I mean to say that concept like CGI programming, OO concepts in Perl, use of different module from CPAN, etc. ...

Why does my regex to match a version number not work?

I'm having perl regex matching problems with a network script I have, I've managed to put the behaviour in a small snippet. Take this Perl snippet for Perl 5.10.0 in Debian: #!/usr/bin/perl use warnings; use strict; my $line = "Version: 0\r\n"; my($version) = $line =~ m/^Version:(\s\d+)\r\n$/; print "1st failed \n" if not $version; ...

What's the minimal set of characters I need to filter before passing a string to a system call?

Assume that the following Perl code is given: my $user_supplied_string = &retrieved_from_untrusted_user(); $user_supplied_string =~ s/.../.../g; # filtering done here my $output = `/path/to/some/command '${user_supplied_string}'`; The code is clearly insecure, but assume that the only thing that can be changed is the filtering code on...

How can I issue an HTTP POST request using only standard Perl libraries?

Assume a system that contains only the basic Perl installation without any extra CPAN modules (LWP is hence NOT installed). Some of my target environments have limited space and I cannot increase my footprint at all (otherwise I would use LWP). What is the most portable and reliable way to issue a HTTP POST request from such a system, a...

/usr/bin/perl: bad interpreter: Text file busy

This is a new one for me: What does this error indicate? /usr/bin/perl: bad interpreter: Text file busy There were a couple of disk-intensive processes running at the time, but I've never seen that message beforein fact, this is the first time that I can remember getting an error when trying to run a Perl script. After a few secon...

Should I use Storable or FreezeThaw to serialize Perl data as a cookie value?

I'd like to store some data in a cookie and my initial though was to pack it myself, but then I remembered that There Is A Module for Everything. I have looked at both Storable and FreezeThaw. Both seem appropriate, though the latter mentions string specifically and seems to serialize into a string without newlines, whereas Storable cr...

Why doesn't my HUP signal handler update the global variable in Perl?

Hello, I'm doing something like the following: I run a Perl script which has the following: # First i install a signal handler for HUP which sets a global flag. $SIG{"HUP"} = sub { print "HUP received\n"; $received_hup = 1 }; # Now i wait for HUP to be received. my $cnt = 0; for ($cnt = 0; $received_hup != 1 and $cnt < 900; $cnt++) { ...

Is there a point to Perl's object oriented interfaces if they're not creating objects?

I think I read somewhere that some modules only have object oriented interfaces ( though they didn't create objects, they only held utility functions ). Is there a point to that? ...

Why is setting the @ISA directly not working in this example?

I have these two modules : package G1; sub new { my $class = shift; my $self = { one => 1, two => 2, three => 3 }; bless $self,$class; return $self; } sub three { my $self = shift; print "G1 green is ",$self->{three}; } 1; package G2; our @ISA = qw(G1); #use base qw(G1); sub new { my ...

Why doesn't Perl's SUPER call use the arrow method?

I noticed that when you call a superclass's methods, you need to do something like this : my $self = $class->SUPER::new(); Why isn't that: my $self = $class->SUPER->new(); ...

Can can I encode spaces as %20 in a POST from WWW::Mechanize?

I'm using WWW::Mechanize to do some standard website traversal, but at one point I have to construct a special POST request and send it off. All this requires session cookies. In the POST request I'm making, spaces are being encoded to + symbols, but I need them encoded as a %20. I can't figure out how to alter this behaviour. I realis...

How do I use a pointer to char from SWIG, in Perl?

Hi, I used SWIG to generate a Perl module for a C++ program. I have one function in the C++ code which returns a "char pointer". Now I dont know how to print or get the returned char pointer in Perl. Sample C code: char* result() { return "i want to get this in perl"; } I want to invoke this function "result" in Perl and pr...

What should the ... operators be called?

The ... operators are identical to the range operator (..) in list context and nearly identical to the flip-flop operator (..) in scalar context, but calling them the range operator and the flip-flop operator seems wrong since those names are more commonly associated with .., which has slightly different behavior (in scalar context at le...

Should my MVC controllers be object-oriented?

I'm making a Perl website, and I'll using Template Toolkit (for the view), a whole bunch of objects for DB interaction and business logic (the model), but I'm wondering: should the controllers be OO? I feel like they should, just for consistency, but it also feels it might be a bit redundant when I'm not interacting with the controllers...

In Perl are there disadvantages to generating getters and setters rather than hard-coding them?

In the example module below, the getters and setters are generated by adding anonymous subroutines to the symbol table. After the methods have been created in this manner, will the resulting code be functionally equivalent (in terms of behavior, speed, etc.) to a module with manually-written getters and setters, or does this approach hav...

Perl: write speed mystery?

How can the output rate be higher than hard disk write rate? Update 1: I have changed the following: Turned off antivirus. No change. Inserted new physical disk and used the first partition for the test. (The disk for the initial test was on the last partition, separate from the system partition, but on the same physical disk.). Resul...

How do I install XML::LibXML for ActivePerl?

I am new to Perl and I am using ActivePerl. I am getting the following error: Can't locate XML/LibXML.pm in @INC... I have tried everything but cannot find the steps to install the "correct" module for XML::LibXML. Here is exactly what is going on. I am running a script from a command prompt: c:\temp>perl myscript.pl The fir...

How can I select a random listbox item with WWW::Mechanize?

With Perl's WWW::Mechanize module, I want to select a random value from a select box. How can I do this? With dump_forms I can dump select box values, but how can I get them in an array? ...

How can I get dynamically web content using Perl?

Hi, This is kind of tricky. There is this webpage which, I am guessing, uses some kind of AJAX to pull out content based on the search query. When I fetch the page using get in Perl, it fetches the script code behind the php/html, but not the results which are displayed when the query is searched manually. I need to be able to fetch th...