#!/usr/bin/perl ############################################################ # slice -- Grab a slice from a file. Specify from-line and # to-line. # Mike Schilli , 2002 ############################################################ use strict; use warnings; use Pod::Usage; our $VERSION = "0.01"; our $CVSVERSION = '$Revision: 1.4 $'; my($from, $to) = splice @ARGV, 0, 2; if(!$from or !$to or $from !~ /^\d+$/ or $from !~ /^\d+$/) { pod2usage(); exit 1; } my $in_slice = 0; my $count = 0; while(<>) { $count++; if($in_slice) { print $_; } else { if($count >= $from) { $in_slice = 1; print $_; } } last if $count >= $to; } =head1 NAME slice - Grab a slice from a file defined by a line range =head1 DOWNLOAD _SRC_HERE_ =head1 SYNOPSIS slice from_line to_line [file] from_line: Line number to start the slice with to_line: Line number to end the slice with file: File name =head1 OPTIONS =head1 DESCRIPTION B opens the given file or STDIN and prints the lines starting from C and ending at C. =head1 EXAMPLES $ slice 1 3 /etc/passwd ... prints the first three lines of /etc/passwd. $ cat /etc/passwd | slice 5 10 ... prints lines 5 to 10 of /etc/passwd. =head1 LEGALESE Copyright 2002 by Mike Schilli, all rights reserved. This program is free software, you can redistribute it and/or modify it under the same terms as Perl itself. =head1 AUTHOR 2002, Mike Schilli