Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
For 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
HTML Tokeparser problem

Posted by TedH (TedH), 15 April 2007
Hi Graham, got a bit of an odd one.

I'm using HTML::Tokeparser in a sub-routine and get an error.

Can't call method "get_tag" on an undefined value

My existing code:
if ($p->get_tag("title")) {
 my $title = $p->get_trimmed_text;

Should it be:
if ($p->get_tag("title", "/title")) {
 my $title = $p->$p->get_trimmed_text([$endtag];

It's odd, because the existing code works on one domain on my server fine. Exactly the same on another domain comes up with the error. I'm wondering if the code I've used is right in the way it uses the HTML::tokeparser module? If it isn't and the module is still waiting for something, then it might be possible that when I run the script on the second site the "HTML::tokeparser" won't work right because it's still waiting for the code on the first site's script to finish.

Deos that make sense?

Hope you can help,
thanks - Ted

Posted by admin (Graham Ellis), 19 April 2007
Ted, sorry I've taken a while to follow up.

It won't be an issue with interacting sights, I'm sure - much more a data specific issue relating to the failing sight.  But having said that, this isn't a module I use so I can't be too much further help.  

By the way - are you sure that the error message related to the source code lines you gave (or to another call to get_tag, perhaps internal to another method?  And is the second site different in any way - for example with badly formed tags?  If you switch the sites round and analyse the second one first, how does the problem move?

Posted by TedH (TedH), 19 April 2007
Hi Graham, been a bit busy today.

I've got some other domains of mine on the same server so uploaded the blog script to there. Did the comment and the mailout notification worked a treat. No Tokeparser error, just the proper deal, Got my email fine  

I can only assume that the domain that had the error has some sort of setting I don't know about (odd?) so will have to contact my tech support.

Other than that, it's been nice and warm here. Was out for a bit this afternoon enjoying the weather. Kay says hi to Lisa.

Posted by TedH (TedH), 19 April 2007
Graham, I have a funny feeling it's the domain name.

From what I can see and HTML Tokeparser both do a variety of things with the hyphen character. I don't understand it much, but, my domain name has a hyphen in. The other 2 domains I've tried this on do not have a hyphen.

Other stuff that uses works okay, it only appears to happen when used in conjunction with the Tokeparser module that I get an error on domain with a hyphen in.

Does that make sense?  

Posted by admin (Graham Ellis), 20 April 2007
I would test that hypothesis by running the same thing on identical code on two domains.

Will pass on your"hi" to Lisa - we're running a buisness networking evening here tonight!

Posted by TedH (TedH), 20 April 2007
Hi Graham, just got finished doing all that.

I ran it on three domains, one with a hyphen in the domain name and it was the only one which errored.

I was just trying to get the title of the page from between the title tags. I've dropped the Tokeparser usage altogteher and just using the link to the page by itself.

Still seeing if I can do a really simple extraction to get the text between the title tags without using a module that might cause conflicts. I think LWP might do so am checking that out as it's standard on all servers (as far as I know). Thing is the script uses the CGI qw(:standard) on other bits.

B invited me to his network and I've signed on there. Never been on one before. Have fun this evening - Ted

Posted by TedH (TedH), 20 April 2007
Okay Graham, sorted it. Back to one of the topics from Geekmas - K.I.S.S.

Instead of complex extraction methods, the data can just as easily be written into a variable in the first place, then called when needed. A lot less code and bother.

It's all about a comment function and notification on the blog sytem I'm writing (now at beta stage). So when a comment is made, the little 6 line script throws out the title in a variable and it gets sent along with a link when mailed out. Comments end with each month and all non-essential files are deleted including the one with that variable.

I'd complicated myself into a corner  

cheers - Ted

This page is a thread posted to the opentalk forum at and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2024: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: • WEB: • SKYPE: wellho