Just print line 25 of a file

Suppose you only want to print a single line of a file, which for convenience is indicated by line 25

perl -ne '$. == 25 && print && exit' file.txt

Of course if we also want to print lines 31 and 57

perl -ne '($. == 25 || $. == 31 || $. == 57) && print' file.txt

While we wanted all the lines between 25 and 57 included

perl -ne 'print if $. >= 25 && $. <= 57' file.txt