[Perl]Modules From Scratch: updating examples

There is this excellent tutorial on how to write Perl Fvwm modules from scratch. Although perfectly documented in the man page (execute fvwm-perllib cat FVWM::Module in your terminal), there are some minor changes in the syntax that may confuse a newcomer to Perl Modules (like me) if using information from some older web pages. This is the example given in the first post with up-to-date syntax (fvwm-2.6.5):

[code]#!/usr/bin/env perl

use strict;
use warnings;

use lib fvwm-perllib dir;
use FVWM::Module;
use FVWM::EventNames;

my $module = FVWM::Module->new(
Mask => M_STRING,
Debug => 1,
);

a bit of chatter to show its working

(this is shown in .xsession-errors or the file you have set-up

with, for example, ‘fvwm 2> .fvwm-errors’ in .xinitrc )

$module->show_message(“FvwmRingMenu starting up”);

add a handler for string events - this is the SendToModule event

$module->add_handler(
M_STRING, sub {
my $mod = shift;
my $event = shift;
my $text = $event->{ arg_values }[3];
$mod->show_message( "Message Received: " . $text );
}
);

$module->event_loop;[/code]
The path where the module is located has to be included in your config file like, for example:

ModulePath $HOME/.fvwm/Modules:+

In a FvwmConsole, writing:

Module FvwmRingMenu

Echoes in .xsession-errors (or equivalent file):

[FvwmRingMenu]: FvwmRingMenu starting up

Afterwards, writing in the FvwmConsole:

SendToModule FvwmRingMenu 12321

You get in .xsession-erros:

[FvwmRingMenu]: Message Received: 12321

Hope this is helpful.
Cheers!