open my $in, "/dev/urandom" or die "couldn't open random: $!"; open my $out, ">a_file.bin" or die "couldn't open output file: $!"; eval { alarm 1; my $buf; read $in, $buf, 1024 or die "error reading: $!"; my $orig = select $out; local $| = 1; select $orig; print $out $buf; }; close $in; close $out;