| 1 | # *|* PERL *|* | ||||||||||
| 2 | # | ||||||||||
| 3 | # Print to multiple filehandles with a single call | ||||||||||
| 4 | # | ||||||||||
| 5 | # File: Multi.pm | ||||||||||
| 6 | # | ||||||||||
| 7 | # Author: Nem W Schlecht | ||||||||||
| 8 | # Last Modification: $Date: 1998/08/07 23:30:57 $ | ||||||||||
| 9 | # | ||||||||||
| 10 | # $Id: Multi.pm,v 1.1 1998/08/07 23:30:57 nem Exp $ | ||||||||||
| 11 | # $Log: Multi.pm,v $ | ||||||||||
| 12 | # Revision 1.1 1998/08/07 23:30:57 nem | ||||||||||
| 13 | # Initial revision | ||||||||||
| 14 | # | ||||||||||
| 15 | # | ||||||||||
| 16 | # Copyright © 1996 by Nem W Schlecht. All rights reserved. | ||||||||||
| 17 | # This is free software; you can distribute it and/or | ||||||||||
| 18 | # modify it under the same terms as Perl itself. | ||||||||||
| 19 | # | ||||||||||
| 20 | |||||||||||
| 21 | package IO::File::Multi; | ||||||||||
| 22 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 23 | 1 | ▶ | use IO::File; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 24 | 1 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 25 | |||||||||||
| 26 | 1 | ▶ | use vars qw($VERSION); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 27 | 1 | our $VERSION = '1.03'; | |||||||||
| 28 | |||||||||||
| 29 | sub new { | ||||||||||
| 30 | 2 | ▶ | my $class = shift; | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 31 | 2 | return bless( {}, $class ); | |||||||||
| 32 | } | ||||||||||
| 33 | |||||||||||
| 34 | # | ||||||||||
| 35 | # add another output | ||||||||||
| 36 | sub open { | ||||||||||
| 37 | 5 | ▶ | my $self = shift; | ||||||||
|
Subroutine
open: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||
| 38 | 5 | my $fh = new IO::File; | |||||||||
| 39 | 5 | ▶ | $fh->open(@_) || carp( ref($self), " - open failed: '@_'" ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 40 | 5 | push( @{ $self->{handles} }, $fh ); | |||||||||
| 41 | } | ||||||||||
| 42 | |||||||||||
| 43 | # | ||||||||||
| 44 | # Return refs to IO::File objects | ||||||||||
| 45 | sub members { | ||||||||||
| 46 | 1 | ▶ | my $self = shift; | ||||||||
|
Subroutine
members: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 47 | 1 | return @{ $self->{handles} }; | |||||||||
| 48 | } | ||||||||||
| 49 | |||||||||||
| 50 | # | ||||||||||
| 51 | # IO::File stub routine | ||||||||||
| 52 | sub fh_st { | ||||||||||
| 53 | 6 | ▶ | my $self = shift; | ||||||||
|
Subroutine
fh_st: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||
| 54 | 6 | my (@args) = @_; | |||||||||
| 55 | 6 | my $ret; | |||||||||
| 56 | 6 | my $sub_call = ( split( /::/o, ( caller(1) )[3] ) )[-1]; # Ack! | |||||||||
| 57 | 6 | for ( @{ $self->{handles} } ) { | |||||||||
| 58 | 16 | $ret = $_->$sub_call(@args); | |||||||||
| 59 | } | ||||||||||
| 60 | 6 | return $ret; | |||||||||
| 61 | } | ||||||||||
| 62 | |||||||||||
| 63 | # | ||||||||||
| 64 | # Clean up. | ||||||||||
| 65 | sub DESTROY { | ||||||||||
| 66 | 2 | ▶ | my $self = shift; | ||||||||
|
Subroutine
DESTROY: called CC=1 SCAR=0.0
| |||||||||||
| 67 | 2 | $self->close(); | |||||||||
| 68 | } | ||||||||||
| 69 | |||||||||||
| 70 | 3 | ▶ | sub print { my $I = shift; $I->fh_st(@_); } | ||||||||
|
Subroutine
print: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 71 | 1 | ▶ | sub printf { my $I = shift; $I->fh_st(@_); } | ||||||||
|
Subroutine
printf: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 72 | 2 | ▶ | sub close { my $I = shift; $I->fh_st(@_); } | ||||||||
|
Subroutine
close: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 73 | 0 | ▶ | sub autoflush { my $I = shift; $I->fh_st(@_); } | ||||||||
|
Subroutine
autoflush: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 74 | 0 | ▶ | sub output_field_separator { my $I = shift; $I->fh_st(@_); } | ||||||||
|
Subroutine
output_field_separator: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 75 | 0 | ▶ | sub output_record_separator { my $I = shift; $I->fh_st(@_); } | ||||||||
|
Subroutine
output_record_separator: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 76 | 0 | ▶ | sub format_page_number { my $I = shift; $I->fh_st(@_); } | ||||||||
|
Subroutine
format_page_number: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 77 | 0 | ▶ | sub format_lines_per_page { my $I = shift; $I->fh_st(@_); } | ||||||||
|
Subroutine
format_lines_per_page: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 78 | 0 | ▶ | sub format_lines_left { my $I = shift; $I->fh_st(@_); } | ||||||||
|
Subroutine
format_lines_left: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 79 | 0 | ▶ | sub format_name { my $I = shift; $I->fh_st(@_); } | ||||||||
|
Subroutine
format_name: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 80 | 0 | ▶ | sub format_top_name { my $I = shift; $I->fh_st(@_); } | ||||||||
|
Subroutine
format_top_name: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 81 | 0 | ▶ | sub format_line_break_characters { my $I = shift; $I->fh_st(@_); } | ||||||||
|
Subroutine
format_line_break_characters: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 82 | 0 | ▶ | sub format_formfeed { my $I = shift; $I->fh_st(@_); } | ||||||||
|
Subroutine
format_formfeed: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 83 | |||||||||||
| 84 | # | ||||||||||
| 85 | # IO::File::Multi doesn't do input (yet - and maybe it never will) | ||||||||||
| 86 | # | ||||||||||
| 87 | #sub getline { my $I = shift; $I->fh_st(@_); } | ||||||||||
| 88 | #sub getlines { my $I = shift; $I->fh_st(@_); } | ||||||||||
| 89 | #sub input_record_separator { my $I = shift; $I->fh_st(@_); } | ||||||||||
| 90 | #sub input_line_number { my $I = shift; $I->fh_st(@_); } | ||||||||||
| 91 | |||||||||||
| 92 | __END__ | ||||||||||