Re: Problems with MIDI:Opus

[email protected] ("Sean M. Burke") Tue, 18 Sep 2001 17:11:17 -0600
Newsgroups perl.midi
Message-ID <[email protected]>
At 10:04 PM 2001-09-18 +0200, Stefano Rodighiero wrote:
>[...]
>	my $song = MIDI::Opus->new(
>		from_file => $file,
>	) || die "Non riesco a leggere il file - $!\n";
>[...]
but the docs say:
my $opus = MIDI::Opus->new({ 'from_file' => $one, 'no_parse' => 1 });

note the braces:           ^                                      ^


I don't recall where I got the idea for bundling the options up in a
hashref.  It had some good points, but I've since stopped doing that, in
classes I designed after MIDI-Perl.  I've also started being unhappy with
constructor paramaters which needlessly duplicate methods -- but that's
another story.

If I had it to do over again, the syntax would be something like:
	my $song = MIDI::Opus->new_from_file($file) || die;
or
       my $song = MIDI::Opus->new;
       $song->parse_from_file($file) || die;
Ahwell, live and learn.


--
Sean M. Burke  [email protected]  http://www.spinn.net/~sburke/