perl

WWW::Mechanize::GZip triggering __DIE__ signal...why?

It's taken me a while to track down a sudden problem with my code, but it appears that WWW::Mechanize::GZip is somehow triggering my $SIG{DIE} handler. Consider this code: use strict; use WWW::Mechanize::GZip; $SIG{__DIE__} = sub { print "WTF??? WHY IS THIS BEING TRIGGERED?\n"; }; my $mech = WWW::Mechanize::GZip->new(); $mech->ge...

In Perl, How Do I Determine If There's a Standard Input Present?

I've got a script that grabs standard input: (code snippet) &process_input sub process_input { while(<STDIN>) { $log_data .= $_; } } When I run the script: myscript.pl -param1=a -param2=b I get stuck in this subroutine. Everything runs ok if I do: echo "" | myscript.pl -param1=a -param2=b Question is how do I dete...

Subversion svn update - Not working

Hi guys, I'm trying to setup subversion, so everytime someone commits a change, it updates a working directory that we'll use on a dev box as the 'test' site. I've setup post-commit, and added the line: #!/usr/bin/perl /usr/bin/svn update /home/administrator/sites/checkmyid --username root --password xxx Can anyone tell me why this ...

Why Do I keep getting SSL failed negotiation?

I'm using XMLRPC::PurePerl to connect to an xmlrpc server. I keep getting a 500 SSL Negotiation failed when I try to establish a connection. Here's the code snippet: my $server = new XMLRPC::PurePerl("https://192.168.1.5/server.php"); my $res = $server->call('TestMessage', $arguments); This doesn't happen on another server where I'...

Where is the documentation for Perl's builtin `Internals::` package?

When using keys %:: to get a list of the currently loaded root namespaces, the Internals:: package is loaded by default (along with UNIVERSAL:: and a few others). However, I haven't found any documentation for the functions in Internals:: keys %{Internals::} returns SvREFCNT hv_clear_placeholders hash_seed SvREADONLY HvREHASH rehash_se...

Perl module for parsing natural language time duration specifications (similar to the "at" command)?

I'm writing a perl script that takes a "duration" option, and I'd like to be able to specify this duration in a fairly flexible manner, as opposed to only taking a single unit (e.g. number of seconds). The UNIX at command implements this kind of behavior, by allowing specifications such as "now + 3 hours + 2 days". For my program, the "n...

Perl - Package/Module Issues

From everything I've read on using Perl modules, the basic usage is: Module file with .pm extension, which includes the statement package <name>, where <name> is the filename of the module without the extension. Code file that uses module contains the statement use <name>;. The application I'm coding has one main code script which us...

Best way to use "isa" method?

What is the "best" way to use "isa()" reliably? In other words, so it works correctly on any value, not just an object. By "best", I mean lack of un-handled corner cases as well as lack of potential performance issues, so this is not a subjective question. This question mentions two approaches that seem reliable (please note that the ...

DynaLoader seeing wrong values in @INC

I have multiple versions of Perl installed; each under a different directory. e.g. C:\Perl\5.x.y. I switch between them in a shell by setting PERL5LIB and altering my PATH so that only one version is visible at a time. Normally, this works fine, but when trying to run the version of pp (PAR::Packer) installed under 5.10.1 I have problems...

Question about DBD::CSB Statement-Functions

From the SQL::Statement::Functions documentation: Function syntax When using SQL::Statement/SQL::Parser directly to parse SQL, functions (either built-in or user-defined) may occur anywhere in a SQL statement that values, column names, table names, or predicates may occur. When using the modules through a DBD or in any other con...

Can I pull the next element from within a Perl foreach loop?

Can I do something like the following in Perl? foreach (@tokens) { if (/foo/){ # simple case, I can act on the current token alone # do something next; } if (/bar/) { # now I need the next token, too # I want to read/consume it, advancing the iterator, so that # the next loop iterat...

How can I use CPAN as a non-root user?

I want to install perl modules on a shared server on which I do not have root access. How can I do this? They also seem to have an older version of CPAN (it complains about that when running the command), is it possible to update the CPAN command being used from my account without requiring root access? ...

When does the difference between a string and a number matter in Perl 5?

If a string in Perl 5 passes looks_like_number, it might as well be a number. For instance, my $s = "10" + 5; results in $s being assigned 15. Are there any cases where a string does not behave like it's numeric equivalent would have? ...

Parsing Wiki XML Dumps ver0.4 just got tough

Hello, I am trying to parse Wikipedia XML Dump using "Parse-MediaWikiDump-1.0.4" along with "Wikiprep.pl" script. I guess this script works fine with ver0.3 Wiki XML Dumps but not with the latest ver0.4 Dumps. I get the following error. Can't locate object method "page" via package "Parse::MediaWikiDump::Pages" at wikiprep.pl line 390. ...

Autodetect console output encoding in perl

I have a perl script that prints some information to console in Russian. Script will be executed on several OSes, so console encoding can be cp866, koi8-r, utf-8, or some other. Is there a portable way to detect console encoding so I can setup STDOUT accordingly so the text is printed correctly? ...

Do you know a database written in Perl with DBI interface?

Hi, Do you know a database written purely in Perl with DBI interface? Or what can be used if there is no MySql or Postgresql installed and I want to use Perl only? Thank you. Ok, I just wanted something that can be used with Catalyst. ...

Perl graph garbage collection usage

Hi, I have built a tiny application in Perl that displays a graph over time. It graphs garbage collection usage over time. I use gnuplot to display the actual graph. This works fine if the time period is short, like a few hours. However, as the time increases (say a few days), the graph becomes difficult to read as the information ge...

API Wrapper Architecture Best Practice

Hi, I'm writing a Perl wrapper module around a REST webservice and I'm hoping to have some advice on how best to architect the module. I've been looking at a couple of different Perl modules for inspiration. Flickr::Simple2 is basically one big file with methods wrapping around the different methods in the Flickr API, e.g. getPhotos()...

Perl regex matching output from `w -hs` command

I'm trying to write a Perl script that will work better with KDE's kwrited, which, as far as I can tell, is connected to a pts and puts every line it receives through the KDE system tray notifications with the title "KDE write daemon". Unfortunately, it makes a separate notification for each and every line, so it spams up the system tra...

How do I convert a regex with pack and hex from Perl to Python?

I am a newcomer to Python and am converting a Perl script. What is the Python equivalent to... $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; Any help is greatly appreciated. ...