If you copy @$row[7] into a string variable you will see that its value is 1. What you meant is $$row[7] or $row->[7]. Any variable starting with @ is an array, so you cannot pass it to encode_utf8.
>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 > > >----- Mensagem original ---- >De: "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> >Para: Bianca Shibuya <[EMAIL PROTECTED]>; macosx@perl.org >Cc: [EMAIL PROTECTED] >Enviadas: Sábado, 27 de Setembro de 2008 21:54:30 >Assunto: Re: Res: Res: Parsing of undecoded UTF-8 will give garbage when >decoding entities > >encode_utf8(@$row[7]) > >@$row[7] is not a string, it's an array containing the eighth element of @$row. >Make sure what you are passing to encode_utf8 is a string by having >your program print out the value. > >-pc > > > > >>The warning is still there. >> >>The code is below: >> >> 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) { ## foreach $ts ($te->tables) >> if ($cont_table == 1) { ## Reporter's name is stored in Table 1 >> Row 0 >> $cont_row = 0; >> foreach $row ($ts->rows) { >> if ($cont_row == 0) { >> if(!defined @$row[7]) { >> $reporter = '';} >> else { >> $reporter = encode_utf8(@$row[7]);} >> last; >> } >> $cont_row++; >> } >> >> } >>......... >> } >> >>The error is at this line: $te->parse($page); but as it is an array.. I >>applied the encode_utf8 at its strings. >>I have applied decode too (according to "To convert an input string of bytes >>which represents a UTF-8 string, into Perl's internal string format, we >>DECODE the byes to from UTF-8") but the error persists. >> >>Any help is welcome! >>Thanks in advance. >> >>Bianca >> >> >>----- Mensagem original ---- >>De: Bianca Shibuya <[EMAIL PROTECTED]> >>Para: [EMAIL PROTECTED]; macosx@perl.org >>Enviadas: Sábado, 27 de Setembro de 2008 20:08:22 >>Assunto: Res: Parsing of undecoded UTF-8 will give garbage when decoding >>entities >> >>Ow.. that is right. Thank you! I will try it. >> >> >> >> >>----- Mensagem original ---- >>De: "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> >>Para: Bianca Shibuya <[EMAIL PROTECTED]>; macosx@perl.org >>Cc: [EMAIL PROTECTED] >>Enviadas: Sábado, 27 de Setembro de 2008 19:58:27 >>Assunto: Re: Parsing of undecoded UTF-8 will give garbage when decoding >>entities >> >>You have to pass strings to encode_utf8, so call it after converting the >>tables to strings, whenever that occurs. What you tried, >>encode_utf8($te->parse($page)), is passing encode_utf8 an arrayref, which >>cannot work. The other things you tried are incorrect. >>-pc >> >>>Hi people! >>>It is me again. =( >>> >>>I am having this warning: Parsing of undecoded UTF-8 will give garbage when >>>decoding entities. >>> >>>I have read that the solution is: The solution is to use the >>>Encode::encode_utf8() on the data before feeding it to the $p->parse(). >>> >>>Ok then use the function encode_utf8(). But how? >>> >>>I have this piece of code: >>> >>> 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) { >>> (...) >>> >>> I tried to use: encode_utf8($te->parse($page)); >>> >>> or: $te = encode_utf8(parse($page)); >>> or: $te-> encode_utf8(parse($page)); >>> or $var->encode_utf8(parse($page)); and where there is $te->tables, place >>> it by $var->tables >>> >>>You can see I dont know how to use it X-| >>> >>>Help me! Thank you. >>> >>>Bianca >>> >>> >>> 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 >>> >> >> >> 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 >> >> >> >> 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 >> > > > 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 >