perl

Is there a Perl module for converting YAML files into Moose objects dynamically at runtime?

I've been trying to find a Perl module that converts a YAML file into moose objects without having to pre-declare the structure as you seem to need to do when using MooseX::YAML. Does anyone know of such a module (or script)? ...

Javascript regex compared to Perl regex

I'm just a noob when it comes to regexp... I know Perl is amazing with regexp... and I dont know much Perl. Recently started learning JavaScript and came across regex for validating user inputs... haven't used them much. How does JavaScript regexp compare with Perl regexp? Similarities and differences? Can all regexp(s) wriiten in ...

What is the PHP equivalent to Perl's regex alternations?

I'm converting one of my old Perl programs to PHP, but having trouble with PHP's string handling in comparison to Perl. In Perl, if I wanted to find out if $string contained this, that or the_other I could use: if ($string =~ /this|that|the_other/){do something here} Is there an equivalent in PHP? ...

XML vs YAML vs JSON

Assuming I'm starting a project from scratch, which is not dependent on any other project. I would like to use a format to store feeds, something like XML, since XML is not the only available format of its kind, I would like to know: why should I choose one over the rest? I will be using perl. 'Feed' is a description of a product (name...

HTML::TreeBuilder::XPath: identifing the xpath-expression

Hello good evening dear -Coder on Stackoverflow! finally back again! i am currently workin on a parser script: I have to parse all the detail-pages of this site here: [link text][1] Note: a very big and powerful suiss site - a governmental server with lots of power! There are several ways to do it. i have to get rid of a lot of crap b...

How fast is Perl's smart match operator for searching scalar in an array?

I want to repeatedly search for values in array, that does not change during the script. So far, I have been doing it this way: I put the values in a hash (so I had an array and a hash with essentialy the same thing) and I searched through exists. I found out, that there is a ~~ operator in perl 5.10. The question is - how efficient it...

DBI database handle with AutoCommit set to 0 not returning proper data with SELECT?

This is a tricky one to explain (and very weird), so bear with me. I will explain the problem, and the fix for it, but I would like to see if anyone can explain why it works the way it works :) I have a web application that uses mod_perl. It uses MySQL database, and I am writing data to a database on regular basis. It is modular, so it ...

How can I modify a local HTML file in Perl?

Is there a CPAN module or code snippet that I can use to modify local HTML files without using a regExp? What I want to do : Change the start tag ( example : <div> to <div id="newtag"> ) Add a tag before another ( example : </head> to <script type="text/javascript"> ...</script></head> Remove tags Read the content of a given tag. (<-...

Which Perl module can format a number with a variable number of leading zeros?

Could somebody tell me a Perl module with a function, that converts digits like this: func( 1, 3 ) # returns 001 func( 23, 4 ) # returns 0023 func( 7, 2 ) # returns 07 ...

What is the recommended way of doing date arithmetics in Perl?

What is the recommended way of doing date arithmetics in Perl? Say for example that I want to know the date three days ago from today (where today = 2010-10-17 and today - 3 days = 2010-10-13). How would you do that in Perl? ...

How can I check for aaa or aab or a in a Perl string?

Can anybody tell me what pattern do I need to write in the bind expression if I want to check whether the string contains aaa or aab or a? $str = "Hello how are aaa you?"; print $str =~ m/what should i write here?/; ...

Should I use an alternative from CPAN to replace Frontier::RPC2?

I have been using Frontier::RPC2 for my XML-RPC server, with Frontier::Client on the client side... but have noticed these modules have not been maintained recently. Discussion at the bottom of this page mentions some fresher alternatives on CPAN. What would the pros and cons of these be? I honesty don't have an immediate need to swit...

Can Perl's HTML::Selector::XPath be used for the general purpose of finding XPaths?

Can Perl's HTML::Selector::XPath be used for the general purpose of finding XPaths? use HTML::Selector::XPath; my $selector = HTML::Selector::XPath->new("li#main"); $selector->to_xpath; # //li[@id='main'] # functional interface use HTML::Selector::XPath 'selector_to_xpath'; my $xpath = selector_to_xpath('div.foo'); ...

How can I get App::cpanminus to work?

I have just installed a fresh copy of ubuntu 10.10. I installed perl 5.12.2 following brian d foy's recommended outline and then installed cpanminus by invoking curl -L http://cpanmin.us | perl5.12.2 - --sudo App::cpanminus. Now, cpan5.12.2 works fine, but whenever I try to install a module using cpanm5.12.2 it fails finding it. e.g.: ...

Is there any Perl Module available to send messages to Office Communicator?

Is there any Perl module available to send messages to Office Communicator? I searched in CPAN but without any luck. Can I use Python or Ruby to send messages to Office Communicator. I want to do this from a Linux Box. ...

How do I execute a perl script in java?

Hi, How do I use java to execute a perl script. Thanks a bunch :) ...

Getting different results with $var !~ ?/?

I am parsing an XML file, and after extracting some information, I want to see if a particular field has a '/' (slash) in it. So I do the following code: if (defined($orgUIDLookup{$orgUidMid})) { my $country = $orgUIDLookup{$orgUidMid}; print "country = $country "; if ($country !~ ?/?) { print "OK\n"; $a...

How can I conditionally import a package in Perl?

I have a Perl script which uses a not-so-common module, and I want it to be usable without that module being installed, although with limited functionality. Is it possible? I thought of something like this: my $has_foobar; if (has_module "foobar") { << use it >> $has_foobar = true; } else { print STDERR "Warning: foobar not...

How should I maintain my object modules in Perl?

I'm writing some object module in Perl using Moose. I use to store instances of created objects then use them. The basic representation of my object's data remains the same, but from time to time I add more functionalities - e.g. class methods or object methods. Can I continue using my stored objects, which were created with an earlier...

How can I extract URLs from plain text in Perl?

I've seen some posts like this, but not exactly what I want to do. How can I extract and delete URL links, and then remove them from plain text. Example: "Hello!!, I love http://www.google.es". I want extract the "http://www.google.es", save it on a variable, and then, remove it from my text. Finally, the text has to be like that: ...