perl

Complex line parse - need help.

Could you help me to correct my parse code. constant fixup privite ConfigAlarms = <U1 0> /* comment here*/ Slip of my code below, I don't know how to get the value of U1 and 0 and **/* comment here*/**. if(/^\s*(constant)\s*(fixup|\/\*fixup\*\/|)\s*(private|)\s*(\w+)^ ...(Need help here.) { $name1 = $1; # for content ...

Crawling engine architecture - Java/ Perl integration

Hi all, I am looking to develop a management and administration solution around our webcrawling perl scripts. Basically, right now our scripts are saved in SVN and are manually kicked off by SysAdmin/devs etc. Everytime we need to retrieve data from new sources we have to create a ticket with business instructions and goals. As you can...

Managing Signal Handling for daemons that fork()

I want to write a robust daemon in perl that will run on Linux and am following the template described in this excellent answer. However there are a few differences in my situation: First I am using Parallel::ForkManager start() and next; to fork on an event immediately followed by exec('handle_event.pl') In such a situation, I have the...

Why does my Perl PAR application immediately die?

This is probably a newbie question as I have just started using pp. I read the documentation on CPAN and tried to create an executable for my application. I use Camelbox and Tk on Windows XP, PAR::Packager version 0.991 (PAR version 0.994). To make sure pp works I created a very simple hello_world.pl using Tk, compiled it into an .exe an...

How can I embede chinese characters in my Perl source?

Hi Guys , In my script I need to "qw" some chinese character into a string . when I run the script , perl conplains that there is unrecognized character in the script . Although I know it must related to encode related stuff , but I don't know how to solve it . so turn to you for help . thanks in advance . ...

How can I render HTML as text using Perl as Lynx does?

Possible Duplicate: Which CPAN module would you recommend for turning HTML into plain text? Question: Is there a module to render HTML, specifically to gather the text, while adhering to font-style tags, such as <tt>, <b>, <i>, etc and break-line <br>, similar to Lynx. For example: # cat test.html <body> <div id="foo" c...

How do I extract and parse quoted strings in Perl?

Hello. Good day. My text file content below. tmp.txt (a very big size file) constant fixup private AlarmFileName = <A "C:\\TMP\\ALARM.LOG"> /* A Format */ constant fixup ConfigAlarms = <U1 0> /* U1 Format */ constant fixup ConfigEvents = <U2 0> /* U2 Format */ My parse code below. The code can't handle C:\\TMP...

A quick string checksum function in Perl generating values in the 0..2^32-1 range

I'm looking for a Perl string checksum function with the following properties: Input: Unicode string of undefined length ($string) Output: Unsigned integer ($hash), for which 0 <= $hash <= 2^32-1 holds (0 to 4294967295, matching the size of a 4-byte MySQL unsigned int) Pseudo-code: sub checksum { my $string = shift; my $hash...

How do I display data from the beginning of a file until the first occurence of a regular expression?

How do I display data from the beginning of a file until the first occurrence of a regular expression? For example, if I have a file that contains: One Two Three Bravo Four Five I want to start displaying the contents of the file starting at line 1 and stopping when I find the string "B*". So the output should look like this: One T...

Where can I find books or tutorials for Perl's POE?

Could someone provide a link to a book on POE (Perl object environment) if there any book like this? Or could someone provide a good tutorial about POE in addtion to the tutorials that found under this site http://poe.perl.org? ...

How can I do a multi-line match on the data returned from Perl's diamond operator

Is there some trick to do multi-line regular expression matches with <>, and loop over them? This example results in no matches when run on files with \n as the newline separator: while (<> =~ m/\n./) { print($.); } I need to know the line of the start of the match inside the while loop, as in the example. The goal is to find all l...

How can I escape a literal string I want to interpolate into a regular expression?

Is there a built-in way to escape a string that will be used within/as a regular expression? E.g. www.abc.com The escaped version would be: www\.abc\.com I was going to use: $string =~ s/[.*+?|()\[\]{}\\]/\\$&/g; # Escapes special regex chars But I just wanted to make sure that there's not a cleaner built-in operation that I'm m...

How to match Chinese character using perl's regex

Hi Guys, I need to match some chinese character in a utf8 encoded html , and I wrote some test code as below : #! /usr/bin/perl use strict; use LWP::UserAgent; use Encode; my $ua = new LWP::UserAgent; my $request = HTTP::Request->new('GET'); my $url = 'http://www.boc.cn/sourcedb/whpj/'; $request->url($url); my $res = $ua->request($...

Is there a tool to convert DBIx::Class Schema (or just SQL) to XSD

I am using perl DBIx::Class ORM and would like to be able to dynamically generate an XSD either from the DBIX::Class schema or directly from the SQL DDL. I know it would probably be better that we start with XSD and generate our SQL DDL from the XSD but we are not in a position to do that yet. thanks, Tom ...

How to rename files in a for loop in Perl

Hi, I am running a Perl script and try to accomplish renaming files as below.. I have a list of *.ru.jp files in a folder with other non related files. I would like to rename with a number which I have got as a counter variable. In Bash,I would do as ... for i in $(ls *.ru.jp); do x=${i%%.*}; mv $i "$x"t"$counter".ru.jp ;done E.g...

How to handle code coverage of both Perl scripts and modules?

I have a unique requirement of handling code coverage of my Perl scripts. I have written a few Perl scripts which in turn uses a few Perl modules. My requirement is to use run these Perl scripts with different options they support and assess the code coverage of both Perl scripts and Perl modules. So I am using Devel::Cover, Module::Bu...

How was Google.com made?

I'm very curious as to what programming languages were used to make Google. In the early days, Larry Page and Sergey Brin tried to licence their search algorithm to Yahoo. What I would love to know is what language(s) was the software first written in? I have a feeling it was C or perl (CGI), anyone know for sure? Thank you in advance ...

Perl: mocking -d -f and friends. How to put them into CORE::GLOBAL

The CORE documentation has shown me how to merrily mock various built Perl functions. However, I'm not really sure how to replace '-d' &c. with my methods. So this is really just a question on how do i replace a function with a dash in it in CORE::GLOBAL. A manual reference would be nice. package Testing::MockDir; use strict; use warn...

Decoding URI related entities with Perl

I may not even be referring to this the proper way so my apologies in advance. Our server logs are constantly showing us an encoded style of attack. An example is below.... http://somecompany.com/script.pl?var=%20%D1%EB........ (etc etc) I am familiar with encoding and decoding HTML entities using Perl (using HTML::Entities) but I am ...

Conditional Work Queue Insertion for beanstalkd?

I'm using the Perl client of beanstalkd. I need a simple way to not enqueue the same work twice. I need something that needs to basically wait until there are K elements, and then groups them together. To accomplish this, I have the producer: insert item(s) into DB insert a queue item into beanstalkd And the consumer: while ( 1 ) ...