#!/usr/bin/perl
use strict;
use warnings;
use IO::Handle;
open (INPUT, "myfile") || die $!;
if (my $fh = STDIN->fdopen(\*INPUT, "r")) {
print <>;
$fh->close;
}
close INPUT;
####
{
local *STDIN;
open(STDIN,'myfile');
#local *STDIN = *MYFILE;
print <>;
close(STDIN);
}
####
my @lines = (
'a string with numbers and letters 4678',
'5678',
'46789',
' 4678',
'4678',
);
open (INPUT, '+<', "tmpfile") || die $!;
print INPUT $_."\n" for @lines;
seek(INPUT,0,0);
if (my $fh = STDIN->fdopen(\*INPUT, "r")) {
my $room = enter_number();
$fh->close;
print "Room: $room\n";
}
close INPUT;
unlink 'tmpfile';