perl

What's behind the 'system' function in Perl?

I can thought that it will open a shell, execute the parameter (shell command) and return the result in a scalar. But, execute system function in a Perl script is faster than a shell command. It will call this command in C? If yes, what's the difference between rmdir foo and system('rmdir foo'); ...

Why am I getting a closed filehandle error when using the diamond operator in list context in Perl?

This code: foreach my $file (@data_files) { open my $fh, '<', $file || croak "Could not open file $file!\n"; my @records = <$fh>; close $fh; .... } produces this error: readline() on closed filehandle $fh at nut_init_insert.pl line 29. and I have no idea why. EDIT: The original post had ',' instead of '<' in th...

Is there a good Perl book on cryptology?

Is there a good Perl book on cryptology? ...

What do I gain by filtering URLs through Perl's URI module?

Do I gain something when I transform my $url like this: $url = URI->new( $url )? #!/usr/bin/env perl use warnings; use strict; use 5.012; use URI; use XML::LibXML; my $url = 'http://stackoverflow.com/'; $url = URI->new( $url ); my $doc = XML::LibXML->load_html( location => $url, recover => 2 ); my @nodes = $doc->getElementsByTagName( ...

How can I define an empty array in a Perl construtor?

I am just beginner with Perl, so if it sounds stupid - sorry for that :) My problem is - I am trying to write a class, which has an empty array, defined in constructor of a class. So I am doing this like this: package MyClass; use strict; sub new { my ($C) = @_; my $self = { items => () }; bless $self, ref $C ...

What CPAN module can summarize Perl error logs?

I'm maintaining some website code that will soon dump all its errors and warnings into a log file. In order to make this a bit more pro-active I plan to parse this log file daily, summarize the warnings and errors (i.e. count the occurrence of each specific one and group by either warning/error) and then email this to the devs on the pro...

Rebuilding lazily-built attribute when an underlying attribute changes in Moose

I've got a Moose class with a lazy_build attribute. The value of that attribute is a function of another (non-lazy) attribute. Suppose somebody instantiates the class with a value of 42 for the required attribute. Then they request the lazy attribute, which is calculated as a function of 42. Then, they have the nerve to change the first...

Is there a Perl module to test internet connection speed?

Does anybody know a module to test the speed of internet-connection? ...

How can I profile a subroutine without using modules?

I'm tempted to relabel this question 'Look at this brick. What type of house does it belong to?' Here's the situation: I've effectively been asked to profile some subroutines having access to neither profilers (even Devel::DProf) nor Time::HiRes. The purpose of this exercise is to 'locate' bottlenecks. At the moment, I'm sprinkling pri...

Why does the web page I fetch with Perl look odd?

I have a Perl script to open this page http://svejo.net/popular/all/new/ and filter the names of the posts but except headers everything seems encrypted. Nothing can be read. When I open the same page in a browser everything looks fine including the source code. How is it possible to encrypt a page for a script and not for a browser? My ...

Why isn't Perl's File::GlobMapper exporting globmap?

The following is pretty well copied from the documentation. use File::GlobMapper qw( globmap ); for my $pair (globmap '<*.tar.gz>' => '<#1.tgz>' ) { } And it gives String found where operator expected at globmapper_test1.pl line 4, near "globmap '<*.tar.gz>'" (Do you need to predeclare globmap?) ...

How do I convert a date from MM/YY/DD to Mon Day, Year in Perl?

I need to convert a date to a string. The date is entered as 07/04/2010 and should then read July 4th 2010. It should also be able to be entered using singe digits instead of double (7 instead of 07, and it needs to add the 20 to the year if the user enters only /10). This is what I have so far - #!/usr/bin/perl use CGI qw(:standard)...

How can I run Perl system commands in the background?

#!/usr/bin/env perl use warnings; use strict; use 5.012; use IPC::System::Simple qw(system); system( 'xterm', '-geometry', '80x25-5-5', '-bg', 'green', '&' ); say "Hello"; say "World"; I tried this to run the xterm-command in the background, but it doesn't work: No absolute path found for shell: & What would be t...

How can I get file size in Perl before processing an upload request?

I want to get file size I'm doing this: my $filename=$query->param("upload_file"); my $filesize = (-s $filename); print "Size: $filesize ";` Yet it is not working. Note that I did not upload the file. I want to check its size before uploading it. So to limit it to max of 1 MB. ...

Why does Perl's Net::Msmgr hang when I try to authenticate?

There's Net::Msmgr module on CPAN. It's written clean and the code looks trustworthy at the first glance. However this module seems to be beta and there is little documentation and no tests :-/ Has anyone used this module in production? I haven't managed to make it run by now, because it requires all event loop processing to be done in ...

How do I install Perl's Parse::Lex for ActivePerl?

Hi I am using ActivePerl 5.10.1 on Win XP. I can't find Lex package from the PPM list. Can I install other package to enable Parse::Lex? ...

How can I extract and save values from an XML file in Perl?

Here is what I am trying to do in a Perl script: $data=""; sub loadXMLConfig() { $filename="somexml.xml" $data = $xml->XMLin($filename); } sub GetVariable() { ($FriendlyName) = @_; switch($FriendlyName) { case "My Friendly Name" {print $data->{my_xml_tag_name}} .... .... ......

Is there a list comparing the features of different frameworks available for developing web apps in Perl?

I've recently been learning perl and am wondering what frameworks are available for creating a web app. I'm mostly concerned about security, so if there are any security-specific web frameworks you'd recommend, I'd be more interested in those. Currently accepted answer from thread below ...

How can I check if contents of one file exist in another in Perl?

Requirement:- File1 has contents like - ABCD00000001,\some\some1\ABCD00000001,Y,,5 (this indicates there are 5 file in total in unit) File2 has contents as ABCD00000001 So what i need to do is check if ABCD00000001 from File2 exist in File1 - if yes{ print the output to Output.txt till it finds another ',Y,,X'} else{ No keep che...

What is the release date for Rakudo Star (perl6)?

If a specific release date is not available (as I suspect it is not), can you provide resources for tracking how close it is to the desired feature set that allows release. I'm not necessarily asking for a percentage gauge, or X of Y features completed list. A list of bugs marked in whichever section of the perl RT instance that's trac...