bcrowell2 has asked for the wisdom of the Perl Monks concerning the following question:

Greetings, O monks,

I'm trying to get Audio::OSS working. The following are the first two lines of the code sample given in the cpan doc:

use Audio::OSS qw(:funcs :formats :mixer); my $dsp = IO::Handle->new("</dev/dsp") or die "open failed: $!";

When I run this on my system, I get this: Can't locate object method "new" via package "IO::Handle" at a.pl line 2.

Can anyone suggest what I need to do here?

TIA!

-Ben

Replies are listed 'Best First'.
Re: code example from Audio::OSS doc fails?
by johna (Monk) on Dec 15, 2010 at 19:52 UTC
    Did you try adding:
    use IO::Handle;
    at the top?

      Thanks for the reply :-)

      If I do that, I get this:
      usage: new IO::Handle at a.pl line 4

      If I then do this:

      use IO::Handle; use Audio::OSS qw(:funcs :formats :mixer); my $dsp = new IO::Handle("</dev/dsp") or die "open failed: $!";
      I get the same error.
        Maybe try changing IO::Handle to IO::File.
Re: code example from Audio::OSS doc fails?
by atanug (Initiate) on Dec 16, 2010 at 12:09 UTC

    Try this one. This should work.

    use IO::Handle; $io = new IO::Handle; open FILE, "</dev/dsp"; if ($io->fdopen(fileno(FILE),"r")) { print $io->getline; $io->close; } else { print "Error\n"; } close FILE;