- foreach my $reader ( '3M810', 'CPRM02' ) {
- next if $only && $only ne $reader;
- my $module = "RFID::Serial::$reader";
- eval "use $module";
- die $@ if $@;
- my $rfid = $module->new( device => '/dev/ttyUSB0' );
- my $visible = $rfid->scan;
- foreach my $tag ( keys %$visible ) {
- warn "XXX $tag";
- print "$reader\t$tag\t", join('', @{ $visible->{$tag} }), $/;
- }
- }
+ my @visible = $rfid->tags(
+ enter => sub {
+ my $tag = shift;
+ print localtime()." enter ", tag($tag);
+
+ },
+ leave => sub {
+ my $tag = shift;
+ print localtime()." leave ", tag($tag);
+ },
+ );
+
+ warn localtime()." visible: ",join(' ',@visible),"\n";