Here's a slightly more complicated example of an engine that powers two methods, one which prints data records to STDIN and one to file.
Once again, we first look at the interfaces or 'wrappers'.
sub print_to_screen { my $class = shift; my %data = %$class; _print_engine(\%data, \%reserved); }
sub print_to_file { my ($class, $outputfile) = @_; my %data = %$class; my $oldfh = select OUT; open(OUT, ">$outputfile") || die; _print_engine(\%data, \%reserved); close(OUT) || die; select($oldfh); }
Previous | Back to start of show | Next |
Slide: 17 print_screen_file | © 2003 James E. Keenan |