Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Perl Beginners > html trees Can'...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 2 Topic 11012 of 11065
Post > Topic >>

html trees Can't call method "as_text" on unblessed reference

by patrick.j.rice@[EMAIL PROTECTED] (Pat Rice) May 1, 2008 at 04:59 PM

Hi all
getting the following error with html trees,
I think its due to not using a global variable.

but when I try an "our" variable for the tree object I still hit the
same issue, i htnk my problem is getting the orignal object.


Any ideas ????


Can't call method "as_text" on unblessed reference at ./lastTouched3.pl
line 77.



Code:

     65 my $TreeTest_SR_INCrementer;
     66 my $SR_Number_as_text = "0.1.0.4.1.0";
     67 my $counter =1;
     68 foreach my $item_r ($tree->address("$address")->content_refs_list)
{
     69 #    next if ref $$item_r;
     70 #    $$item_r =~ s/honour/honor/g;
     71         $counter++;
     72         print "\n in for each: $counter \n";
     73
     74         my $srIncrementer = "$SR_Number_as_text.$counter.0";
     75         print "\n in for each: $srIncrementer\n";
     76
     77         $TreeTest_SR_INCrementer =$item_r->as_text;
     78         print "\n sr = $TreeTest_SR_INCrementer";
     79
     80  }



Full code

      1 #!/usr/bin/perl
      2
      3 use strict;
      4 use HTML::Tree;
      5 use LWP::Simple;
      6 use Encode;
      7
      8
      9 #my $funky = "http://www.google.com";
     10
     11 my $funky = "html page -- removed http";
     12
     13 my $content = get($funky);
     14
     15 #print $content;
     16 #aiming to get the following
     17
     18
     19 #print "\n **************Regexes******************\n";
     20
     21 #if($content =~ /SRId=/) {
     22 #       print "\n in if statment";
     23 #       print "\nThe first digit is $1.";
     24 #}
     25
     26
     27
     28
     29 my $tree = HTML::Tree->new();
     30 #local $tree = HTML::Tree->new();
     31
     32
     33 $tree->parse($content);
     34
     35 #print $tree->as_text;
     36
     37 ##change here 17:51 dumping all data
     38 #print "\n Trying to dump here\n ";
     39 #print $tree->dump;
     40
     41
     42 #<a
href="http://vmweb.vmware.com/vmwarestore/internalstore/sr_detail.jsp?SRId=1104943561"
target="new"> @[EMAIL PROTECTED]
     43
     44 print "This returns the node (whether element or text-segment)
at the given address in the tree that \$h is a part of.\n";
     45 my $address ="0.1.0.4.1.0.1.0";
     46 my $TreeTest = $tree->address("$address")->as_text;
     47
     48 print "\nThe first node of the tree address ($address) is:
$TreeTest \n";
     49
     50
     51 my $address ="0.1.0.4.1.0.2.0";
     52 my $TreeTest = $tree->address("$address")->as_text;
     53 print "\nThe first node of the tree address ($address) is:
$TreeTest \n";
     54
     55
     56
     57
     58 my $address ="0.1.0.4.1.0";
     59 my $TreeTestContent_list =
$tree->address("$address")->content_list();
     60 print "\n TreeTestContent_list = $TreeTestContent_list\n";
     61 my $TreeTest = $tree->address("$address")->as_text;
     62 print "\nThe first node of the tree address ($address) is:
$TreeTest \n";
     63
     64
     65 my $TreeTest_SR_INCrementer;
     66 my $SR_Number_as_text = "0.1.0.4.1.0";
     67 my $counter =1;
     68 foreach my $item_r ($tree->address("$address")->content_refs_list)
{
     69 #    next if ref $$item_r;
     70 #    $$item_r =~ s/honour/honor/g;
     71         $counter++;
     72         print "\n in for each: $counter \n";
     73
     74         my $srIncrementer = "$SR_Number_as_text.$counter.0";
     75         print "\n in for each: $srIncrementer\n";
     76
     77         $TreeTest_SR_INCrementer =$item_r->as_text;
     78         print "\n sr = $TreeTest_SR_INCrementer";
     79



Thanks
Pat




 2 Posts in Topic:
html trees Can't call method "as_text" on unblessed reference
patrick.j.rice@[EMAIL PRO  2008-05-01 16:59:21 
Re: html trees Can't call method "as_text" on unblessed referenc
rob.dixon@[EMAIL PROTECTE  2008-05-01 18:09:18 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed May 14 23:23:42 CDT 2008.