in reply to Equivalent code for input line operator on a scalar?

Sure, see. IO::Scalar e.g
use IO::Scalar; my $output = <<TXT; this is the first line and this is the second line but this is the last TXT my $scalar_fh = IO::Scalar->new(\$output); print while <$scalar_fh>; __output__ this is the first line and this is the second line but this is the last
HTH

_________
broquaint