@input = qw/here is some input/; my $imfile = join "\n",@input; open(MEMORY,'+<', \$imfile) or die "Can't open memory file: $!"; # Then use IO::Handle or open to just override STDIN. # To be comprehensive you could check the version of perl. If it's not high enough, you could require IO::String, to solve the problem, as well..