perl

How can I call a Perl subroutine from Flex?

I'm new to Perl as well as Flex. I've just gone through the basic (and exciting) stuff in both of them. I just want to call a Perl subroutine from Flex. Is it possible? If so how? ...

Match over multiple lines perl regular expression

Hi, I have a file like this: 01 00 01 14 c0 00 01 10 01 00 00 16 00 00 00 64 00 00 00 65 00 00 01 07 40 00 00 22 68 61 6c 2e 6f 70 65 6e 65 74 2e 63 6f 6d 3b 30 30 30 30 30 30 30 30 32 3b 30 00 00 00 00 01 08 40 00 00 1e 68 61 6c 2e 6f 70 65 6e 65 74 2d 74 65 6c 65 63 6f 6d 2e 6c 61 6e 00 00 00 00 01 28 40 00 00 21 72 65 61 6c 6d 31 2e ...

How can I modify a scalar reference passed to a subroutine reference?

I have a function to convert documents into different formats, which then calls another function based on the type document. It's pretty straight forward for everything aside from HTML documents which require a bit of cleaning up, and that cleaning up is different based on where it's come from. So I had the idea that I could pass a refer...

How do I sort a Perl hash that has tons of data?

I am sorting a hash in Perl. I encountered an Out of memory error when running my Perl Script: foreach $key (sort (keys(%hash))) { .... } How do I sort a hash that has tons of data? ...

What is the Perl equivalent to pygame?

Are there any Perl equivalents for pygame? EDIT: I have found SDL and perl-ogre, but I'm looking for something more "high level" ...

How do I load a module at runtime in Perl?

Is it possible to load a module at runtime in Perl? I tried the following, but it didn't work. I wrote the following somewhere in the program: require some_module; import some_module ("some_func"); some_func; ...

XML::LibXML: How to get a Number/Boolean-object with find?

From http://search.cpan.org/~pajas/XML-LibXML-1.70/lib/XML/LibXML/Node.pod: find evaluates the XPath 1.0 expression using the current node as the context of the expression, and returns the result depending on what type of result the XPath expression had. For example, the XPath "1 * 3 + 52" results in a XML::LibXML::Number object bein...

Why does Perl complain "Can't modify constant item in scalar assignment"?

I have this Perl subroutine that is causing a problem: sub new { my $class = shift; my $ldap_obj = Net::LDAP->new( 'test.company.com' ) or die "$@"; my $self = { _ldap = $ldap_obj, _dn ='dc=users,dc=ldap,dc=company,dc=com', _dn_login = 'dc=login,dc=ldap,dc=company,dc=com', ...

How can I convert japanese characters to unicode in Perl?

Can you point me tool to convert japanese characters to unicode? ...

Is there a reason to use the XML::LibXML::Number-object in my XML::LibXML-example?

In this example I get to times '96'. Is there a possible case where I would need a XML::LibXML-Number-object to to achieve the goal? #!/usr/bin/env perl use warnings; use strict; use 5.012; use XML::LibXML; my $xml_string =<<EOF; <?xml version="1.0" encoding="UTF-8"?> <filesystem> <path> <dirname>/var</dirname> <files> ...

WWW::Mechanize VS Curl

Hi, Background: I need to get updated data for all of my users. The data resides on a secure site so the script needs to login (using cookies) Traverses some inner URLs and then fetch the required data. Tools: WWW::Mechanize or Curl What is the best tool for my needs? Performance is a big issue I need to get th...

What would be the PHP equivalent of this Perl regex?

What would be the PHP equivalent of this Perl regex? if (/^([a-z0-9-]+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)$/ and $1 ne "global" and $1 ne "") { print " <tr>\n"; print " <td>$1</td>\n"; print " <td>$2</td>\n"; print " <td>$3</td>\n"; print " <td>$4</td>\n"; print " <td>$5</td>...

Send invitation to any user of google chats (is it possible?)

Hi I try to realize simple code on perl which should just get/send messages from/to gtalk accounts. I use Net::XMPP::* modules. All works just fine for users, who are my friends (in my "buddy" list). But i can't send message to unknown user. I know, that for this case i must send an invitation first, but Net::XMPP::* don't provide ...

Why don't my Perl regexes correctly extract a filename from a path?

I am trying to parse the filename from paths. I have this: my $filepath = "/Users/Eric/Documents/foldername/filename.pdf"; $filepath =~ m/^.*\\(.*[.].*)$/; print "Linux path:"; print $1 . "\n\n"; print "-------\n"; my $filepath = "c:\\Windows\eric\filename.pdf"; $filepath =~ m/^.*\\(.*[.].*)$/; print "Windows path:"; print $1 . "\n\n";...

How do I insert null fields with Perl's DBD::Pg?

I have a Perl script inserting data into Postgres according to a pipe delimited text file. Sometimes, a field is null (as expected). However, Perl makes this field into an empty string and the Postgres insert statement fails. Here's a snippet of code: use DBI; #Connect to the database. $dbh=DBI->connect('dbi:Pg:dbname=mydb','mydb',...

What is the most idiomatic way to emulating Perl's Test::More::done_testing?

I have to build unit tests for in environment with a very old version of Test::More (perl5.8 with $Test::More::VERSION being '0.80') which predates the addition of done_testing(). Upgrading to newer Test::More is out of the question for practical reasons. And I am trying to avoid using no_tests - it's generally a bad idea not catching w...

Is there a pure Perl module for AES?

Is there a pure Perl module for AES? ...

How do I make a progress bar using Term::ProgressBar with LWP::UserAgent's post method?

#!/usr/bin/perl use LWP::UserAgent; use HTTP::Request::Common; use HTML::TreeBuilder; use Cwd 'realpath'; use warnings; use strict; my $ua = LWP::UserAgent->new(); my $response = $ua->request( POST 'http://mydomain.com/upload.php', 'Content-Type' => 'multipart/form-data', 'Content' => [...

How can I check if a Perl array contains a particular value?

I am trying to figure out a way of checking for the existence of a value in an array without iterating through the array. I am reading a file for a parameter. I have a long list of parameters I do not want to deal with. I placed these unwanted parameters in an array @badparams. I want to read a new parameter and if it does not exist i...

What does it mean when you try to print an array or hash using Perl and you get, Array(0xd3888)?

What does it mean when you try to print an array or hash and you see the following; Array(0xd3888) or HASH(0xd3978)? EXAMPLE CODE my @data = ( ['1_TEST','1_T','1_TESTER'], ['2_TEST','2_T','2_TESTER'], ['3_TEST','3_T','3_TESTER'], ['4_TEST','4_T','4_TESTER'], ['5_TEST','5_T','5_TESTER'], ['6_TEST','6_T','^_TESTER'] ); ...