gsd4me has asked for the wisdom of the Perl Monks concerning the following question:

To the knowledgeable all

from: A confused, stuck prole.

As part of a (self-interest) project, I read in a spreadsheet using Spreadsheet::ReadSXC, downloaded and installed from CPAN - historical reasons for the choice, but not relevant to my query here.

As part of the code sequence, that specific module raised 4 warnings about an uninitialised variable in its operation when a open my source (LibreOffice)spreadsheet. So, muggins here decides to add a print statement to the ReadSXC.pm module held in the perl site library on my laptop, to try and find out what is causing the problem. I did the edit and re-saved the module in the file structure. However, when I now run my project I get the error "Spreadsheet::ReadSXC not installed at ...". So, and this is the crux of my query, - am I not permitted to edit any perl module on my own machine? What is it that 'knows' that the module is not as originally installed and HOW does it know? I haven't changed any version number or any other identifying information in the module. Is it fixable - ie without downloading and re-installing the CPAN source, which will just get me back to my original, observed situation? When I do a CPAN -l, the module is listed as 'undef' if that helps any. I'm afraid I know nothing about any of the Perl 'admin' operational 'structure' so any guidance would be most welcome on this matter.

  • Comment on editing of installed modules, a story of failure

Replies are listed 'Best First'.
Re: editing of installed modules, a story of failure
by LanX (Saint) on Mar 24, 2022 at 22:02 UTC
    > So, and this is the crux of my query, - am I not permitted to edit any perl module on my own machine?

    It's not a good idea, because a future CPAN installation might update it and overwrite your patches.

    It's better to copy it to another path before patching and prepend it to @INC.

    Salva just explained it recently: Re: How to redefine a modules private function?

    To your actual question:

    you most probably entered an error while patching. A guess: the compilation fails during requirement and the module never returns the necessary true value.

    It's hard to tell tho without more details, but did you make sure the new code compiles?

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery

      > A guess: the compilation fails during requirement and the module never returns the necessary true value.

      I've tested this theory by patching Data::Dumper , but it produced accurate errors and not the ones from the OP.

      No problems to undo the changes at the end.

      # --- introduced 'die' before module's end D:\>perl -MData::Dumper -e0 test at C:/Strawberry/perl/lib/Data/Dumper.pm line 852. Compilation failed in require. BEGIN failed--compilation aborted. # --- changed final 1 to 0 D:\>perl -MData::Dumper -e0 Data/Dumper.pm did not return a true value. BEGIN failed--compilation aborted. # --- undid all changes D:\>perl -MData::Dumper -e0 D:\>

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery

      The cpan client can be configured to apply local patches when it installs a module, preserving them across installations. I do not know whether cpanm or cpanp have this capability. Of course, the patches also have to be maintained, but that's only a problem if the module being patched is under active maintenance.

Re: editing of installed modules, a story of failure
by bliako (Abbot) on Mar 25, 2022 at 00:43 UTC

    cpanm -f Spreadsheet::ReadSXC will re-install it (one way to do it) so you can start afresh with your experiments.

Re: editing of installed modules, a story of failure
by ikegami (Patriarch) on Mar 25, 2022 at 13:52 UTC

    What is it that 'knows' that the module is not as originally installed and HOW does it know?

    It does not.

    And it doesn't produce the error message "Spreadsheet::ReadSXC not installed at ..."

    It produces the message "Can't locate Spreadsheet/ReadSXC.pm in @INC".

    That's because Perl looks for a file named Spreadsheet/ReadSXC.pm relative to a directory in @INC.

    Again, it doesn't check if the file has been "changed".

    @INC is influenced by env var PERL5LIB.

Re: editing of installed modules, a story of failure
by Tux (Canon) on Mar 25, 2022 at 14:37 UTC

    Other than all the good replies you already got, *please* stop using Spreadsheet::ReadSXC! It served its purpuse when it was new and no alternatives were available, but it it is unmaintained and buggy (as you already noticed).

    The currect best alternative is using Spreadsheet::ParseODS, which has almost the same API as Spreadhseet::ParseExcel and Spreadsheet::ParseXLSX.

    You can also consider Spreadsheet::Read if you do not need writing, as it is a unifying wrapper over most supported spreadsheet parsers.


    Enjoy, Have FUN! H.Merijn
Re: editing of installed modules, a story of failure
by etj (Priest) on Mar 25, 2022 at 12:03 UTC
    A technique to figure out what's happening right now is the "V" module:
    cpanm V perl -MV=Spreadsheet::ReadSXC # shows locations of installed files
      > # shows locations of installed files

      perldoc -l does that, too. (mostly°)

      D:\>perldoc -l Data::Dump C:\Strawberry\perl\lib\Data\Dump.pm

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery

      °) potential .pod files are usually nearby

      Don't reap this is a problem/bug in the monastery.

      I went back and forth in the history of a an edit sessionsing session of this post.

      This will sometimes repost again, hence not only destroy the last edit but also produce duplicates.


      > # shows locations of installed files

      perldoc -l does that,too. (mostly)

      D:\>perldoc -l Data::Dump C:\Strawberry\perl\lib\Data\Dump.pm

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery

Re: editing of installed modules, a story of failure
by gsd4me (Beadle) on Mar 25, 2022 at 18:58 UTC
    OK - got an answer. As per Lanx's posting, the module was throwing an error on compilation - primarily and solely because the pm file was full of gibberish - symbols inserted/left behind by using Notepad to do the editing by me. Note to self - use a bespoke editor and don't trust anything to do what you would *expect* it to do! Thanks to all for guidance