Res: Res: Res: Res: Parsing of undecoded UTF-8 will give garbage when decoding entities

[email protected] (Bianca Shibuya)
Newsgroups perl.macosx
Message-ID <[email protected]>
Thank you all!

Part of my code is:

sub get_opendate {
   my $URL = shift;
   my $page = get($URL);

   $te = HTML::TableExtract->new(); 
   $te->parse($page); # parse() returns an arrayref containing each table encountered
   
   $cont_table = 0;
   foreach $ts ($te->tables) {   
      if ($cont_table == 4) {       ## Submission date is stored in the table 4
          $cont_row = 0;
          foreach $row ($ts->rows) {      
             if ($cont_row == 0) {
              if(!defined @$row[1]) {
                    $date = '';}
                 else {
                    $date = decode_utf8($row->[1]); }
                 last;
             }
             $cont_row++;
          }
      }
      ## If the bug report has received votes (it changes the HTML structure) than the submission date is stored in Table 5 Row 0
      if (($cont_table == 5) && ($date eq '')) {     
          $cont_row = 0;
          foreach $row ($ts->rows) {      
             if ($cont_row == 0) {
                 $test = decode_utf8($row->[1]);     #### As $date does not accept the value of @$row[1] directly, I had to use a different variable
                 $date = $test;
                 last;
             }
             $cont_row++;
          }
      }  
      $cont_table++;
   } ## Closing the first foreach
   
   print "$date\n";
   
   $year = substr($date, -4);
   $month = substr($date, 12, 3);
   $day = substr($date, 16, 2);

   return $year, $month, $day;
}

How can I change it to make the warning disappear?

Thank you all in advance.

Bianca
----- Mensagem original ----
De: Chas. Owens <[email protected]>
Para: Bianca Shibuya <[email protected]>
Cc: "[email protected]" <[email protected]>; "[email protected]" <[email protected]>
Enviadas: Domingo, 28 de Setembro de 2008 2:19:14
Assunto: Re: Res: Res: Res: Parsing of undecoded UTF-8 will give garbage when     decoding     entities


On Sep 27, 2008, at 10:00, Bianca Shibuya <[email protected]> wrote:

> Thank you for your help.
> But the content of @$row[7] is a string (I have printed out it). If  
> it is not a string, I cannot identify other variable to apply this  
> function. =( Because the rest of the program is a sequence of ifs  
> similar to the last if.
>
> Thanks in advance.
> Bianca

>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>
>>
>>
>>
>>
>>
If you said

print @$row[7];

Then that is equivalent to

print join $,, @$row[7];

To really see the value of that expression you need to say

print map { "[$_] " } @$row[7];

This will print the individual items in the list surrounded by brackets.


      Novos endereços, o Yahoo! que você conhece. Crie um email novo com a sua cara @ymail.com ou @rocketmail.com.
http://br.new.mail.yahoo.com/addresses
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.