|
Hi...
TOTAL n00b question: I started coding what I hope will end up as a useful sccriptlet. It should:
* take strings from File A
* find same strings in File B
* append prefix to File B strings
here's what I have so far. It grabs the strings I want no problem, and I think I've succeeded in opening the second file and storing its lines in an array. Now I just have to match my File A strings with similar strings in File B and append my own string to the beginning of each.
Caveat: File B is not formatted like File A..so I might need a regex to make the match. The strings are actually IP addys, and the only reason I could get away with grabbing them from File A in the way I did was that they are left-justified and have no preceding chars, and I only needed the first 10 chars to uniquely id them.
Thanks Gurus!!!!
!/usr/bin/perl
use strict;
use warnings;
#------------------------------------------------------------
# WHAT: A simple script to perform string swaps between files
# WHO: me
# USAGE: not yet...
#------------------------------------------------------------
my @lines;
my $string;
my @morlines;
# get lines from the File A
open(FILE1,"list") || die "Error: $!\n";
@lines = <FILE1>;
foreach $string(@lines) {
$string=substr($string, 0, 11);
}
# Open File B and get corn-fuzed...
use Tie::File;
tie @morlines, 'Tie::File', "/forum/test1.txt" or die;
for (@morlines) {
do stuff...;
}
|
|
|
|
|
|
|
// |