##################################################################### # # This is a stripped down version of IO::Scalar # Given a reference to a scalar, it supplies either: # a getline method which reads lines (mode='r'), or # a print method which reads lines (mode='w') # ##################################################################### package Perl::Tidy::IOScalar; use strict; use warnings; use Carp; our $VERSION = '20250311'; use constant DEVEL_MODE => 0; use constant EMPTY_STRING => q{}; sub AUTOLOAD { # Catch any undefined sub calls so that we are sure to get # some diagnostic information. This sub should never be called # except for a programming error. our $AUTOLOAD; return if ( $AUTOLOAD =~ /\bDESTROY$/ ); # Originally there was a dummy sub close. All calls to it should have been # eliminated, but for safety we will check for them here. return 1 if ( $AUTOLOAD =~ /\bclose$/ && !DEVEL_MODE ); my ( $pkg, $fname, $lno ) = caller(); my $my_package = __PACKAGE__; print {*STDERR} <[1]; if ( $mode ne 'r' ) { confess <[2]++; return $self->[0]->[$i]; } ## end sub getline sub print { my ( $self, $msg ) = @_; my $mode = $self->[1]; if ( $mode ne 'w' ) { confess <[0] } .= $msg; return; } ## end sub print 1;