Hi there.
So this is my 2nd week perl scripting, and im starting to get the ropes now.
I have two text files, one is created by another perl script that is an output from a cisco router, the other is a text file that lists "Dialer101 to Amsterdam" for example. I am trying to get my script to replace the dialer name with the actual name.
Here is what I have so far
#!e:\perl\bin
$s_output = "cismultilink.txt";
$new_output = "named_output.txt";
$location = "location.txt";
open (SOUT, "<$s_output" or die "cant open $s_output: $!";
open (NOUT, "+>$new_output" or die "cant open $new_output: $!";
open (LOCATION, "<$location" or die "cant open $location: $!";
my ($inline);
my (@inlinearray);
while ($inline = <LOCATION>)
{
if (substr ($inline,0,1) ne "#"
{@inlinearray = split "\t",$inline;
$inlinearray[0] =~ s/[ \t\n\r]*$//g;
$inlinearray[0] =~ s/^[ \t\n\r]*//g;
$dialer = $inlinearray[0];
$dialername = $inlinearray[1];
foreach $pattern ($dialer) {
my $re = qr/$pattern/;
foreach $line(@lines) {
if ($line =~ $re) {
print $inlinearray[1]($line);
print NOUT;
}
}
}
}
}
I guess I could be doing this totally wrong, but then thats why I am asking for help.
Kind regards
Sam
So this is my 2nd week perl scripting, and im starting to get the ropes now.
I have two text files, one is created by another perl script that is an output from a cisco router, the other is a text file that lists "Dialer101 to Amsterdam" for example. I am trying to get my script to replace the dialer name with the actual name.
Here is what I have so far
#!e:\perl\bin
$s_output = "cismultilink.txt";
$new_output = "named_output.txt";
$location = "location.txt";
open (SOUT, "<$s_output" or die "cant open $s_output: $!";
open (NOUT, "+>$new_output" or die "cant open $new_output: $!";
open (LOCATION, "<$location" or die "cant open $location: $!";
my ($inline);
my (@inlinearray);
while ($inline = <LOCATION>)
{
if (substr ($inline,0,1) ne "#"
{@inlinearray = split "\t",$inline;
$inlinearray[0] =~ s/[ \t\n\r]*$//g;
$inlinearray[0] =~ s/^[ \t\n\r]*//g;
$dialer = $inlinearray[0];
$dialername = $inlinearray[1];
foreach $pattern ($dialer) {
my $re = qr/$pattern/;
foreach $line(@lines) {
if ($line =~ $re) {
print $inlinearray[1]($line);
print NOUT;
}
}
}
}
}
I guess I could be doing this totally wrong, but then thats why I am asking for help.
Kind regards
Sam