Tags:
create new tag
view all tags

Question

Hi,

have written a simple little test plugin to see if I understand the logic flows and construction of TWiki. The code in the sub function (sub TableFolderListing) works as a perl script.

Created a txt file from NewPluginTemplate renaming it, placing it in each of the Webs on our server.

Initially I was getting illegal declaration of subroutine error

Plugin "TWiki::Plugins::FolderDisplayPlugin" could not be loaded by Perl.  Errors were:

---- Illegal declaration of subroutine TWiki::Plugins::FolderDisplayPlugin::TableFolderListing at

../lib/TWiki/Plugins/FolderDisplayPlugin.pm line 116.

Compilation failed in require at (eval 21) line 1.

BEGIN failed--compilation aborted at (eval 21) line 1.

Having read perlsub I added a ; at the end of the sub TableFolderListing line (weird as none of the other subs have a ; at the end of the line).

Restarted apache and now get the following errors:

Plugin "TWiki::Plugins::FolderDisplayPlugin" could not be loaded by Perl.  Errors were:

---- TWiki/Plugins/FolderDisplayPlugin.pm did not return a true value at (eval 21) line 1.

BEGIN failed--compilation aborted at (eval 21) line 1.

---- Plugin "TWiki::Plugins::FolderDisplayPlugin" could not be loaded by Perl.  Errors were:

---- TWiki/Plugins/FolderDisplayPlugin.pm did not return a true value at (eval 32) line 1.

BEGIN failed--compilation aborted at (eval 32) line 1.

----

hmm

  • line 1 is a comment, so what are the errors referring to?
  • Are there any other places to look for debug information other than the warnings.txt?
  • Left the txt file as is because couldn't find documentation saying which lines were mandatory (if any). Are there mandatory lines in the .txt files?

I've attached both files below.

Environment

TWiki version: TWikiRelease02Sep2004
TWiki plugins: DefaultPlugin, SpreadSheetPlugin, ApprovalPlugin, CommentPlugin, EditTablePlugin, InterwikiPlugin, RenderListPlugin, SlideShowPlugin, SmiliesPlugin, TablePlugin
Server OS: Win XP Pro
Web server: Apache 1.3.33
Perl version: Perl 5.8.6 (Cygwin)
Client OS: Cygwin 5.1 on XP Pro SP1
Web Browser: IE 6, Firefox
Categories: Plugins

-- SteveMayes - 06 Apr 2005

Answer

  1. You have no braces around your sub. i.e.
sub TableFolderListing
{
...
}
  1. Your package does not end with the (unintuitive but required) line to indicate package load success:
1;

You can check that your perl module is compilable before running it in the TWiki context:

perl -c TWiki::Plugins::YourPluginName.pm

HTH. M.

Martin,

-- MartinCleaver - 06 Apr 2005

Thank you. The perl -c tip is excellent. The required 1; is interesting, I use Arachnophilia as my editor and it has a minor bug wherein it inserts a | at the end of the perl script causing it to crash, consequently I now automatically scan my scripts and remove the trailing | (or in this case the trailing 1).

-- SteveMayes - 06 Apr 2005

Topic attachments
I Attachment History Action Size Date Who Comment
Perl source code filepm FolderDisplayPlugin.pm r1 manage 5.9 K 2005-04-06 - 12:35 UnknownUser  
Texttxt FolderDisplayPlugin.txt r1 manage 2.1 K 2005-04-06 - 12:35 UnknownUser  
Edit | Attach | Watch | Print version | History: r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r4 - 2005-04-06 - CrawfordCurrie
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.