#!/usr/bin/perl use v5.16; open(my $FH, "<", "input.txt") or die "Can't open < input.txt: $!"; my $i; for (0 .. 3) { $i = int(rand(10)); say $i; say $FH $i } close $FH;