samdaman (TechnicalUser) May 16, 2003
Hi. I am a newbie (as you will all see in a moment).
I have a text file example
Dialer129
Dialer195
Dialer303
Dialer145
Dialer201
Dialer145;;0239028;;10;;10;;8
And I need to do the following
If a dialer number appears twice, delete the one that does not have any extra information, so as in the above file
Delete Dialer145
Keep Dialer145;;0239028;;10;;10;;8
Keep all other unique entries like DIaler129 etc.
I must Keep Dialer as it is used in a command line of the router for later.
Here is what I have. I have taken some from a thread off this site, and also from other FAQS. Whilst I have read some (loads of) FAQS, I have been unable to understand them well enough to amend them to my needs. And in the 3 weeks that I have started Perl, I have written some perl scripts to automate cisco router processes, which I was amazed to see work.
Thanks for the use or your knowledge, I hope to add it to my own
Cheers
Sam
open DATA, "<cismultilink.txt";
$Dialer = Dialer149;
$Multi = "Dialer145;;0239028;;10;;10;;8";
@array = ($Dialer, $Multi);
while (<DATA>) {
close DATA;
}
map { $seen{$_}++ } @array;
my @dupes = grep { $seen{$_} > 1 } keys %seen;
print;
close DATA;
__END__
Hi. I am a newbie (as you will all see in a moment).
I have a text file example
Dialer129
Dialer195
Dialer303
Dialer145
Dialer201
Dialer145;;0239028;;10;;10;;8
And I need to do the following
If a dialer number appears twice, delete the one that does not have any extra information, so as in the above file
Delete Dialer145
Keep Dialer145;;0239028;;10;;10;;8
Keep all other unique entries like DIaler129 etc.
I must Keep Dialer as it is used in a command line of the router for later.
Here is what I have. I have taken some from a thread off this site, and also from other FAQS. Whilst I have read some (loads of) FAQS, I have been unable to understand them well enough to amend them to my needs. And in the 3 weeks that I have started Perl, I have written some perl scripts to automate cisco router processes, which I was amazed to see work.
Thanks for the use or your knowledge, I hope to add it to my own
Cheers
Sam
open DATA, "<cismultilink.txt";
$Dialer = Dialer149;
$Multi = "Dialer145;;0239028;;10;;10;;8";
@array = ($Dialer, $Multi);
while (<DATA>) {
close DATA;
}
map { $seen{$_}++ } @array;
my @dupes = grep { $seen{$_} > 1 } keys %seen;
print;
close DATA;
__END__