/[mdap]/lib/MDAP.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /lib/MDAP.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 70 - (show annotations)
Sun Nov 18 10:28:28 2007 UTC (16 years, 5 months ago) by dpavlin
File size: 671 byte(s)
 r102@brr:  dpavlin | 2007-11-18 11:28:23 +0100
 once returns true if this is first time message is seen

1 package MDAP;
2 use Exporter 'import';
3 our @EXPORT = qw/
4 once
5 dump
6 $debug
7 /;
8
9 use strict;
10 use warnings;
11
12 use Data::Dump qw/dump/;
13
14 use Module::Pluggable search_path => 'MDAP', sub_name => 'plugins', require => 1;
15 my @plugins = __PACKAGE__->plugins;
16 warn "## found plugins: ",dump( @plugins );
17
18 our $debug = 0;
19
20 =head1 NAME
21
22 MDAP - common stuff
23
24 =head1 FUNCTIONS
25
26 =head2 once
27
28 once("this message will be reported just once");
29
30 Returns true if this message was seen first time.
31
32 =cut
33
34 our $once;
35
36 sub once {
37 my $m = join('', @_);
38 $once->{$m}++;
39 if ($once->{$m} == 1) {
40 print "$m\n";
41 return 1;
42 }
43 return;
44 }
45
46 sub DESTROY {
47 warn "all messages: ",dump( $once );
48 }
49
50 1;

  ViewVC Help
Powered by ViewVC 1.1.26