7 lines - Output only the given lines of the input stream
13 if(grep {$_ eq '--help'} @ARGV)
15 die "Usage: $0 [<RANGES> [<RANGES> [...]]] [-- <FILE> [<FILE> [...]]]
16 Read from from FILEs if specified, STDIN otherwise.
17 RANGES is comma-delimited list of line numbers and inclusive ranges.
18 Special symbol 'EOF' represents the end of the input file.
28 while(exists $ARGV[0])
35 for my $range (split /,/, $ARGV[0])
37 if($range =~ /^(\d+)(?:-(\d+|EOF))?$/)
39 push @ranges, [$1, $2];
43 die "invalid range: $range\n";
50 eval 'use ARGV::readonly; 1' or die;
54 $. = 1 if $ARGV ne $prev_ARGV;
56 for my $range (@ranges)
58 my ($from, $to) = @
$range;
61 if($. >= $from and ($to eq 'EOF' or $. <= $to)) { $include = 1; }
65 if($. == $from) { $include = 1; }