| 1 |
#! /usr/local/bin/perl -w |
| 2 |
# |
| 3 |
# cb2 - Another simple callback demonstration, showing how |
| 4 |
# a T::C::S object can interact with the outside |
| 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 |
my $at_min = 0; |
| 13 |
my $at_max = 0; |
| 14 |
|
| 15 |
tie my $c, 'Tie::Cycle::Sinewave', { |
| 16 |
start_max => 1, |
| 17 |
min => 0, |
| 18 |
max => 100, |
| 19 |
period => 12, |
| 20 |
at_max => sub { ++$at_max }, |
| 21 |
at_min => sub { ++$at_min }, |
| 22 |
}; |
| 23 |
|
| 24 |
my $iter = 0; |
| 25 |
while( 1 ) { |
| 26 |
printf "%3d %10.2f %2d %2d\n", ++$iter, $c, $at_min, $at_max; |
| 27 |
select undef, undef, undef, 0.2; |
| 28 |
} |