perl

Why does XML:Simple complain that "No element found"?

Hello, I'm trying to execute a simple Perl program that uses XML::Simple to print out the data from an XML file. However, the error I'm getting is : no element found at line 15, column 0, byte 308 at /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi/XML/Parser.pm line 185 The XML file is as follows : <?xml version="1.0"?> <c...

What do you think of MooseX::Declare?

I've stumbled upon the MooseX::Declare documentation, and I have to say "WOW!". That looks really nice! I think it's the cleanest OOP syntax Perl has. use MooseX::Declare; class BankAccount { has 'balance' => ( isa => 'Num', is => 'rw', default => 0 ); method deposit (Num $amount) { $self->balance( $self->balance + $a...

How do I make DBIx::Class join tables using other operators than `=`?

Summary I've got a table of items that go in pairs. I'd like to self-join it so I can retrieve both sides of the pair in a single query. It's valid SQL (I think), the SQLite engine actually does accept it, but I'm having trouble getting DBIx::Class to bite the bullet. Minimal example package Schema; use parent 'DBIx::Class::Schema';...

What's a good Perl reference/tutorial for an experienced programmer?

I'm an experienced programmer but I haven't tried using Perl before. Can anyone please give me a link to a good tutorial of the Perl language? Thank you very much. ...

How can I get a only part of a hash in Perl?

Is there a way to get a sub-hash? Do I need to use a hash slice? For example: %hash = ( a => 1, b => 2, c => 3 ); I want only %hash = ( a => 1, b => 2 ); ...

How do I unescape XML special characters in Perl?

I'm processing some XML files (specifically .vcproj files) in Perl and I want to unescape the special characters. The escaped characters I've encountered so far are: &quot; &#x0D; &#x0A; Obviously I can do this myself but it seems that there should be a standard (or CPAN) module to do this but a naive search brings up nothing relevan...

Why does TextMate always complain 'Can't find string terminator '"'' when it runs a Perl script?

I have a long-ish Perl script that runs just fine, but always gives this warning: Can't find string terminator '"' anywhere before EOF at -e line 1 I've read elsewhere online that this is because of a misuse of single or double quotes and the error generally stops the script from running, but mine works. I'm pretty sure I've used my ...

Finding rendered HTML element positions using WebKit (or Gecko)

Hi, I would like to get the dimensions (coordinates) for all the HTML elements of a webpage as they are rendered by a browser, that is the positions they are rendered at. For example, (top-left,top-right,bottom-left,bottom-right) Could not find this in lxml. So, is there any library in Python that does this? I had also looked at Mechan...

What is does the regular expression /^\s*$/ do?

What does this expression in Perl programming do? $variable =~ /^\s*$/; ...

How can I send XML to a CGI program from Perl?

Hi, I want to send some XML from a Perl program to a CGI script that makes use of XML::Simple to take that XML as input and send XML as output. Is there a way to send XML to a CGI script from Perl? Any help in this regards would be really appreciated. Thank You ...

What does Perl's substr do?

My variable $var has the form 'abc.de'. What does this substr exactly do in this statement: $convar = substr($var,0,index(".",$var)); ...

Should I learn Perl 5 OO or Moose first?

I'm still relatively new to Perl Programming, but I know how Perl 5 OO basically works. However, I have never created any project with Perl 5 OO, so I'm quite sure I will run into many pitfalls. Recently I discovered the hype about the Moose module. I checked out some documentation on CPAN and I found it to be quite interesting and help...

Why is this intended interpolation interpreted as division by Perl?

G'day, Why am I getting the following two errors from the script fragment below? Argument "www4.mh.xxxx.co.uk.logstatsto20090610.gz" isn't numeric in division (/) at line 56 Argument "/logs/xxxx/200906/mcs0.telhc/borg2" isn't numeric in division (/) at line 56 The variables $dir and $log are both strings and the concatenation...

Why don't my variables interpolate correctly into my Perl substitution pattern?

I'm writing a complex script that takes the XML backup of a Blogger blog and converts it to InDesign Tagged Text to be laid out in a book. I'm using a whole bunch of regular expressions to clean out the HTML tags of each blog post and convert them to InDesign tags. For example: <p>A really long paragraph.</p> -> <ParaStyle:Main text>A r...

How can I use a C linked list from Perl XS?

I writing programing with Perl and XS. I need to display and do some operations that use a linked list from C. How can I accomplish that? ...

How can I parse and normalize HTML from different HTML generators?

This is an extension of this question. I'm trying to parse HTML snippets embedded in an XML backup of a Blogger blog and retag them with InDesign tags. Blogger doesn't standardize the HTML for any of its posts, and the posts can be written in Word, Windows Live Writer, the native Blogger interface, or text editors, resulting in tons of ...

Filter filenames by pattern

I need to search for files in a directory that begin with a particular pattern, say "abc". I also need to eliminate all the files in the result that end with ".xh". I am not sure how to go about doing it in Perl. I have something like this: opendir(MYDIR, $newpath); my @files = grep(/abc\*.*/,readdir(MYDIR)); # DOES NOT WORK I also ...

How can I handle unicode with Perl's DBI?

My delicious-to-wp perl script works but gives for all "weird" characters even weirder output. So I tried $description = decode_utf8( $description ); but that doesnt make a difference. I would like e.g. “go live” to become “go live” and not “go live” How can I handle unicode in Perl so that this works? UPDATE: I found the prob...

Is my book too old to learn from? (perl)

Hey guys. The book in question is called 'Learning Perl, Third Edition', by Schwartz and Phoenix - printed by O'Reilly in 2001. Is this book too old? Have there been significant improvements to the language over the last 7/8 years that warrant a newer book on the subject? Thank you. ...

How can I get cross-thread communication in a Perl GTK program?

I have a Perl program that has a GTK2 GUI (via the Gtk2 package). This program also opens a network socket (actually via LWP) in another thread, and continuously makes a request for a certain URL, waiting for an event to happen. If an event occurs, then its data must be processed and interpreted, and an appropriate callback function use...