sub { .... my $string = get_string(); local *STDIN; open(STDIN, '<', \$string) or die "could not open $string"; binmode STDIN; .... }