my $line; my $line_you_want = 2; $line = for 1..$line_you_want; # $line will now contain just the content of line number $line_you_want;