Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Error with CPAN module XML-BMEcat

by syphilis (Archbishop)
on Aug 10, 2017 at 12:24 UTC ( [id://1197159]=note: print w/replies, xml ) Need Help??


in reply to Error with CPAN module XML-BMEcat

I would appreciate any hint into the right direction

I can reproduce the error with:
use warnings; use strict; my @k = (1,2,3); my $self = \@k; # an ARRAY reference my $ret = foo($self, 'key'); print "$ret\n"; sub foo { my ($self, $key) = @_; (exists $self->{$key}) ? return $self->{$key} : return 0; }
Update: But if I set $self to a string (instead of a reference to the array) && I turn off strictures, then the program runs to completion and foo() returns 0.

Cheers,
Rob

Replies are listed 'Best First'.
Re^2: Error with CPAN module XML-BMEcat
by derion (Sexton) on Aug 10, 2017 at 15:21 UTC
    Thank you very much for your feedback Rob. As many other starting to post here I do not feel very experienced and questioning modules listed at CPAN feels wrong but it looks to me that the code should be more like:
    sub creatCatalogGroup { my ($self, $key) = @_; # pls.don't forget this problem (exists @{$self}[0]->{$key}) ? return @{$self}[0]->{$key} : return Push2PsH($self, $key, CatalogGroup->new()); }

    I am not yet sure if it does the right thing, but at least it does not throw an error.

    Cheers

    Niko

      Hi

      Oh wow, thats the authors comment,

      I see the test file is named "Test.pl" most of the cpan-testers didn't run the test file

      I've made fixes, but I've not examined the xml file to check if it makes sense, but the test.pl now runs without problems

      Here is a new version of that distribution, use patch to create it, use patch -p0 -i XML-BMEcat-0.56.patch and get

      patching file XML-BMEcat-0.56/Changes
      patching file XML-BMEcat-0.56/lib/XML/BMEcat.pm
      patching file XML-BMEcat-0.56/Makefile.PL
      patching file XML-BMEcat-0.56/MANIFEST
      patching file XML-BMEcat-0.56/META.json
      patching file XML-BMEcat-0.56/META.yml
      patching file XML-BMEcat-0.56/test.pl
        Thank you very much to all of you especially for trying to update the script.

        the fix is to inherit from Class::PseudoHash

        seems to work perfect.
        I would not have expected that my problems were based in the module and I did not yet know about pseudo-hashes, so also thanks to runrig.
        I am happy with the updates and I have no more errors, works like a charm!

        Bah, forgot about pseudohash stuff I commented out in sub writeGroupSystem , so my patch is meh

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1197159]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2024-04-18 00:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found