Debian Codegraph @

eg/callback

raw
1 #! /usr/local/bin/perl -w
2 #
3 # callback - demonstrate how callbacks can modify the parameters
4 # of a Tie::Cycle::Sinewave object
5 #
6 # This file is part of the Tie::Cycle::Sinewave perl extension
7 # Copyright (c) 2005 David Landgren. All rights reservered.
8
9 use strict;
10 use Tie::Cycle::Sinewave;
11
12 tie my $c, 'Tie::Cycle::Sinewave', {
13 start_min => 1,
14 min => 10,
15 max => 20,
16 period => 4,
17 at_max => sub {
18 my $s = shift;
19 $s->min($s->min() - 2);
20 $s->period($s->period() + 1 );
21 },
22 at_min => sub {
23 my $s = shift;
24 $s->max($s->max() + 5);
25 $s->period($s->period() + 1 );
26 },
27 };
28
29 while( 1 ) {
30 printf "%10.2f\n", $c;
31 select undef, undef, undef, 0.15;
32 }