-------- Original-Nachricht -------- > Datum: Mon, 16 Mar 2009 12:41:01 -0400 > Von: "Chas. Owens" <chas.ow...@gmail.com> > An: Jim Gibson <jimsgib...@gmail.com> > CC: beginners@perl.org > Betreff: Re: Error: Can\'t call method "x" without a package or object > reference...
> On Mon, Mar 16, 2009 at 12:23, Jim Gibson <jimsgib...@gmail.com> wrote: > snip > >> Can't call method "x" without a package or object reference at test.pl > line 12 > >> <ENT> line 1 > snip > >> $ent{$1} = \x{$2}; > snip > > Without seeing all of your data, it is impossible to tell what actually > went > > wrong. Possibly the next line after 'aacute 00E1' did not match, perhaps > > because it was blank or contained something other than one space between > > entries. > snip > > It isn't a data problem. Perl thinks he/she is trying to take the > reference of the item returned by a call to the function x[1] with a > malformed hashref (not an even number of list items). This is because > the \x{} construct is only valid in strings. He/she also has a > problem in that the \x{} does not interpolate values, it requires a > hexadecimal constant. The right answer is the use hex to get the > decimal value of the hexadecimal string he gets from the regex (which > you rightly point out needs to have guards) and to feed that decimal > value into the chr function to get the UNICODE character he/she is > looking for. > > 1. If a function x had existed he/she would have gotten a completely > different error message (i.e. the one about the malformed hash). > > -- > Chas. Owens > wonkden.net > The most important skill a programmer can have is the ability to read. > Thanks, Chas and Jim! Chas' remark was quite right - I somewhat stupidly confused the functions \x{} and char(). Now it does what I wanted it to do. (I also take the point of filehandles and checking whether m// are successful.) Thanks again for your help, MCoiff' -- Psssst! Schon vom neuen GMX MultiMessenger gehört? Der kann`s mit allen: http://www.gmx.net/de/go/multimessenger01 -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/