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