in reply to How do I add a few stings of text, 30 lines before the EOF?
Otherwise, you could find out the length of the file, and then subtract 30 from the end of the length, and insert it there.#!/usr/bin/perl -wT use strict; #get inserted text my @inserted_text = ('Blah','Blah Blah'); # read in the file open (FILE,"filename") or die "Can't open file"; my @file = <FILE> close(FILE) open (OUTFILE,">filename") or die "Can't open file"; my $line = 0; foreach(@file) { if ($line = 569) { foreach(@inserted_text){print OUTFILE;} } $line++; } close(OUTFILE);
This is untested code and, I'd bet 70 monks here could give you much, much better answers. I look forward to seeing them.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: How do I add a few stings of text, 30 lines before the EOF? (update)
by lucasdmc (Initiate) on Oct 16, 2001 at 04:02 UTC | |
by wog (Curate) on Oct 16, 2001 at 04:32 UTC |