You may want to use OO-style then use IO::String package.
#!/usr/bin/perl
use strict;
use warnings;
use IO::String;
my $s="dfasdfasdfafd....\nabc";
my $io = IO::String->new($s);
while (my $line = $io->getline()) {
print $line;
}
print "\nTHE END\n";
# write new line
$io->print("\nappend new line");
# back to the start
$io->seek(0, 0);
while ($io->sysread(my $line, 512)) {
print $line;
}
Also you may use almost all methods described in IO::Handle package.
This solution is useful when some of another package accepts only IO::Handle (IO::File) object to manipulate data.