in reply to Return full line from line number X

Since your file is relatively small, it's a fairly simple task:

#!/usr/bin/perl -w use strict; open F, '<', "myfile" or die "myfile: $!\n"; chomp(my @content = <F>); close F; # Input validation routine my $in; { print "Please enter the line number you want to retrieve (1-" . @c +ontent . "): "; chomp($in = <STDIN>); # line_numbers == array_indexes shifted by + 1 redo unless $in =~ /^\d+$/ && $in > 0 && $in <= @content; } # Now you can play with your retrieved value my ($mnum, $mname) = split / /, $content[$in - 1], 2; print "Number: $mnum Name: $mname\n";

--
"Language shapes the way we think, and determines what we can think about."
-- B. L. Whorf