PyrexKidd has asked for the wisdom of the Perl Monks concerning the following question:
fileA:#!/usr/bun/perl #------------------------------ # This script searches for "search" # and adds lines from fileSource to fileOutput use warnings; use strict; #use Fcntl (:flock :seek); # Check unless(-e $ARGV[0] || -e $ARGV[1]){ print("Please Enter A Valid File Name\n"); exit 1; } #if($ARGV[0] == "--help"){ # print("Usage is:\n"); # print("perl conference_add.pl <Source File> <Output File> <Sear +ch String>"); #} # assigns file path to local variables my($fileSource) = $ARGV[0]; my($fileOutput) = $ARGV[1]; my(@inputLines); # opens files for reading/writing open(FILESOURCE, "<", $fileSource) || die("Can not open $fileSource $! +"); open(FILEOUT, ">>", $fileOutput) || die ("Can not open $fileOutput $!" +); @inputLines = <FILESOURCE>; print FILEOUT @inputLines; close(FILESOURCE); close(FILEOUT);
fileB1 2 3 4 5
end result:a b c d SEARCHPATTERN e f g h i
please help.a b c d SEARCHPATTERN 1 2 3 4 5 e f g h i
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Modifying File in the Middle
by JavaFan (Canon) on Apr 10, 2010 at 19:43 UTC | |
|
Re: Modifying File in the Middle
by tospo (Hermit) on Apr 11, 2010 at 16:40 UTC | |
|
Re: Modifying File in the Middle
by kiruthika.bkite (Scribe) on Apr 12, 2010 at 04:00 UTC |