keys must be hash or array Common.pm

Help
Anonymous
2012-01-03
2013-01-02

  • Anonymous
    2012-01-03

    when I try to install the lxr in my ubuntu11.10, but there are always some errors, and I have not learned perl, I think it is maybe a bug, so I email you and want to be helped!

    zyqhi@lenovo:/usr/local/share/lxr$ ./genxref  -checkonly
    Type of arg 1 to keys must be hash or array (not hash element) at lib/LXR/Common.pm line 114, near "}) "
    Type of arg 1 to keys must be hash or array (not hash element) at lib/LXR/Common.pm line 348, near "}) "
    Compilation failed in require at lib/LXR/Index.pm line 23.
    BEGIN failed-compilation aborted at lib/LXR/Index.pm line 23.
    Compilation failed in require at ./genxref line 27.
    BEGIN failed-compilation aborted at ./genxref line 27.

     
  • Andre-Littoz
    Andre-Littoz
    2012-01-03

    I discovered this also today when I tried to install LXR on my old computer. Apparently, Perl syntax varies in each version of the interpreter.

    I corrected this in CVS by using a strict syntax which is backward compatible with older version of Perl interpreter.
    If you have the latest LXR (release 0.10), send the result of the following command:

    ./genxref --checkonly
    

    To correct the bug, you have 2 options:
    - upgrade your Perl interpreter (use apt-install)
    - wait till I upload a new bug-fix release.

     
  • Andre-Littoz
    Andre-Littoz
    2012-01-03

    It was a quick fix, so I uploaded a fixed release.
    Anyway, send the result of the command above so that I can track the syntax changes in Perl.

    Best regards,
    ajl

     

  • Anonymous
    2012-01-05

    Hi, I'm using  Ubuntu 11.10, with  perl v5.12.4 built for x86_64-linux-gnu-thread-multi. lxr-0.10.2

    ./genxref --checkonly
    Global symbol "$wwwdebug" requires explicit package name at lib/LXR/Common.pm line 65.
    Global symbol "$tmpcounter" requires explicit package name at lib/LXR/Common.pm line 67.
    Global symbol "$wwwdebug" requires explicit package name at lib/LXR/Common.pm line 75.
    Global symbol "$wwwdebug" requires explicit package name at lib/LXR/Common.pm line 84.
    Global symbol "$wwwdebug" requires explicit package name at lib/LXR/Common.pm line 98.
    Global symbol "$tmpcounter" requires explicit package name at lib/LXR/Common.pm line 108.
    Type of arg 1 to keys must be hash or array (not hash element) at lib/LXR/Common.pm line 114, near "}}"
    Compilation failed in require at lib/LXR/Index.pm line 23.
    BEGIN failed--compilation aborted at lib/LXR/Index.pm line 23.
    Compilation failed in require at ./genxref line 27.
    BEGIN failed--compilation aborted at ./genxref line 27.
    

    I change the next lines:

    0065  $wwwdebug = 0;  -> my $wwwdebug = 0;

    0067 $tmpcounter = 23;  ->  my $tmpcounter = 23;

    0114  foreach my $param (keys $HTTP->{'param'}) {   ->  foreach my $param (keys ${$HTTP->{'param'}}) {

    With this changes ./genxref -checkonly works fine. But when I try to explore the code in http://localhost/lxr/source/  Apache show this error (in the log)

     fatal: LXR::Common, line 114: Can't use string ("1") as a HASH ref while "strict refs" in use at /home/papaliza/LXR/lxr/lib/LXR/Common.pm line 114.
    

    I Fix this problem  commenting the line:

    0023 #use strict;
    

    I made this changes before read this thread, I think the best solution is upgrade my perl version. But apt-get install perl returns  "perl is already the newest version". Maybe I need to compile perl from source code to get the newest version.

    Best Regards!

    Pablo.

     
  • Andre-Littoz
    Andre-Littoz
    2012-01-05

    In my Fedora 16 distro, Perl version is 5.14.2 and I think there are some not well documented syntax changes. As a safety measure, I checked LXR on my older computer under 5.12.x. That lead to corrections included in 0.10.2 (thanks to Yuqang Zhou who reported the bugs).

    Your fix for line 114 is incorrect. It should read  … (keys %{$HTTP … I know, Perl syntax is awful! Writing ${$HTTP … you get the number of keys or the existence of keys (boolean value equal to 1), which is not a reference to the parameters.

    I'm quite surprised by the "… requires explicit package name …" messages. LXR works OK for me on both computers. I admit I have not yet reviewed Common.pm to use very strict syntax with maximum bacward compatibility.

    But you should install 0.10.2 because I left an unforgivable bug in search (I forgot to incorporate 2 lines in CVS). Neither 0.10 nor 0.10.1 will operate correctly.

    Thanks for your interest and the return.

    ¡Feliz año nuevo!

    ajl

     
  • change   syntax error  in line

    foreach my $param (%{keys $HTTP->{'param'}) {   ---> foreach my $param (keys %{$HTTP->{'param'}}) {

    to fix problem

     
  • This is sooo lame.

    I expect something more reasonable than NOT COMPILING from the tool I trust my sources.
    Ppl, c'mon apply it and release new version which FUCKIN COMPILES.

    Patch for the lazy ones:

    -- Common.pm.orig      2012-01-03 22:06:15.000000000 +0400
    +++ Common.pm   2012-02-29 22:51:22.000000000 +0400
    @@ -62,9 +62,9 @@
    our $identifier;
    our $HTTP;

    -$wwwdebug = 0;
    +my $wwwdebug = 0;

    -$tmpcounter = 23;
    +my $tmpcounter = 23;

    sub warning {
            my $msg = shift;
    @@ -111,7 +111,7 @@
    sub nonvarargs {
            my @args;

    -       foreach my $param (%{keys $HTTP->{'param'}}) {
    +       foreach my $param (keys %{$HTTP->{'param'}}) {
                    next unless $param =~ m!^_!;
                    my $val = $HTTP->{'param'}->{$param};
                    if (length($val)) {

     
  • Andre-Littoz
    Andre-Littoz
    2012-03-02

    Do you really think that behaving as a  f*** rude b*** will shorten release delivery timeframe?
    If you read carefully http://lxr.sf.net/bugsandlimits.shtml, you'll notice the developper is already aware of the bug. Big effort is currently devoted to automating installation process. This easier (I hope) procedure and the above bug fix will be in 0.11 release. It is nearly ready for distribution but the User's Manual is not yet fully polished.