Perl: "Linux::Input" and problem with IO redirecti
Posted: Tue Feb 21, 2006 3:42 pm
[PROBLEM]
When polling events using the Perl module "Linux::Input", the default output gets shifted to something else. This results in problems when redirecting the output of this script.
Example:
outputs "dingdong"
...leaves us with an empty (0 byte size) test.txt.
[SOLUTION]
According to a friend of mine, the "selector" in "Linux::Input" shifts the default output to something else during polling, but doesn't set it back.
redirecting the output of this version to "test.txt" works fine.
NOTE: Actually, I'm not really sure if that's a bug in Linux::Input or not.
When polling events using the Perl module "Linux::Input", the default output gets shifted to something else. This results in problems when redirecting the output of this script.
Example:
Code: Select all
#!/usr/bin/perl
use Linux::Input::Joystick;
my $js = Linux::Input::Joystick->new("/dev/js0");
while (1) {
my @event = $js->poll(0.01);
printf("ding dong\n");
}
Code: Select all
$> ./myscript.pl
Code: Select all
$> ./myscript.pl > test.txt
[SOLUTION]
According to a friend of mine, the "selector" in "Linux::Input" shifts the default output to something else during polling, but doesn't set it back.
Code: Select all
#!/usr/bin/perl
use Linux::Input::Joystick;
my $js = Linux::Input::Joystick->new("/dev/js0");
while (1) {
my @event = $js->poll(0.01);
printf STDOUT "ding dong\n";
}
NOTE: Actually, I'm not really sure if that's a bug in Linux::Input or not.