in reply to printing specific lines
#! /usr/bin/perl -w use strict; use Fcntl 'O_RDONLY'; use Tie::File; # Path to file containing lines as arg my $linesPath = shift; # Tie the file read-only, if you want to read only, to be safe tie my @linesFile, 'Tie::File', $linesPath, mode => O_RDONLY or die "Can't open file $linesPath: $!"; while(<DATA>) { chomp; # $_ - 1, I'm assuming that the list isn't 0-based print "$linesFile[$_ - 1]\n"; } untie @linesFile; __DATA__ 1 3 4 7
|
|---|