| 1 | ########################################################################### | ||
| 2 | # | ||
| 3 | # Native.pm | ||
| 4 | # | ||
| 5 | # Copyright (C) 1999 Raphael Manfredi. | ||
| 6 | # Copyright (C) 2002-2017 Mark Rogaski, mrogaski@cpan.org; | ||
| 7 | # all rights reserved. | ||
| 8 | # | ||
| 9 | # See the README file included with the | ||
| 10 | # distribution for license information. | ||
| 11 | # | ||
| 12 | ########################################################################## | ||
| 13 | |||
| 14 | 8 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 15 | |||
| 16 | ######################################################################## | ||
| 17 | package Log::Agent::File::Native; | ||
| 18 | |||
| 19 | # | ||
| 20 | # A native Perl filehandle. | ||
| 21 | # | ||
| 22 | # I'm no longer using the IO::* hierarchy because it is not adapted | ||
| 23 | # to what we're trying to achieve here. | ||
| 24 | # | ||
| 25 | |||
| 26 | # | ||
| 27 | # ->make | ||
| 28 | # | ||
| 29 | # Creation routine. | ||
| 30 | # Turns on autoflush as a side effect. | ||
| 31 | # | ||
| 32 | 32 | ▶ | sub make { |
|
Subroutine
make: called CC=1 SCAR=0.0
Pod
documented
| |||
| 33 | 32 | my $class = shift; | |
| 34 | 32 | my ($glob) = @_; | |
| 35 | 32 | select((select($glob), $| = 1)[0]); # autoflush turned on | |
| 36 | 32 | return bless $glob, $class; | |
| 37 | } | ||
| 38 | |||
| 39 | # | ||
| 40 | |||
| 41 | # | ||
| 42 | # Print to file, propagates print() status. | ||
| 43 | # | ||
| 44 | 75 | ▶ | sub print { |
|
Subroutine
print: called CC=1 SCAR=0.0
Pod
documented
| |||
| 45 | 75 | my $glob = shift; | |
| 46 | 75 | local $\ = undef; | |
| 47 | 75 | return CORE::print $glob @_; | |
| 48 | } | ||
| 49 | |||
| 50 | # | ||
| 51 | # ->close | ||
| 52 | # | ||
| 53 | # Close file. | ||
| 54 | # | ||
| 55 | 19 | ▶ | sub close { |
|
Subroutine
close: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 56 | 19 | my $glob = shift; | |
| 57 | 19 | CORE::close $glob; | |
| 58 | } | ||
| 59 | |||
| 60 | # | ||
| 61 | # ->DESTROY | ||
| 62 | # | ||
| 63 | 19 | ▶ | sub DESTROY { |
|
Subroutine
DESTROY: called CC=1 SCAR=0.0
| |||
| 64 | 19 | my $glob = shift; | |
| 65 | 19 | CORE::close $glob; | |
| 66 | } | ||
| 67 | |||
| 68 | 8 | 1; # for require | |
| 69 | __END__ | ||