Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Q

Status
Not open for further replies.

samdaman

Technical User
Oct 23, 2002
23
NZ
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, &quot;<cismultilink.txt&quot;;
$Dialer = Dialer149;
$Multi = &quot;Dialer145;;0239028;;10;;10;;8&quot;;
@array = ($Dialer, $Multi);
while (<DATA>) {
close DATA;
}
map { $seen{$_}++ } @array;
my @dupes = grep { $seen{$_} > 1 } keys %seen;
print;

close DATA;

__END__
 
Sorry I must have deleted the subject line before submitting post. If someone can, please delete this entry as i have added it again.

Or if I can, please let me know how, but cant see that

Thanks

Sam
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top