#!/usr/bin/perl use strict; use Tie::File; #deletes first nbytes of a file die "Usage: $0 file numbytes\n" unless @ARGV == 2; my ($file, $nbytes) = @ARGV; my $ncount=0; my $line; tie my @raw_data, 'Tie::File', $file , autochomp => 0 or die "Cannot O +pen $file: $!"; while (1){ $line = shift @raw_data; while($line){ $line = substr ($line,1); $ncount++; if($ncount >= $nbytes ){last} } if ($ncount >= $nbytes ){last;} } unshift @raw_data,$line; untie @raw_data; exit 0;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: head truncate
by Aristotle (Chancellor) on Sep 12, 2002 at 18:49 UTC | |
by sauoq (Abbot) on Sep 13, 2002 at 01:00 UTC | |
by Aristotle (Chancellor) on Sep 13, 2002 at 13:26 UTC | |
by sauoq (Abbot) on Sep 13, 2002 at 20:03 UTC | |
by Aristotle (Chancellor) on Sep 13, 2002 at 21:18 UTC | |
| |
|
Re: head truncate
by zentara (Cardinal) on Sep 12, 2002 at 20:18 UTC | |
|
Re: head truncate
by zentara (Cardinal) on Sep 12, 2002 at 20:36 UTC |