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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Perl Text File Help

Status
Not open for further replies.

Core2

IS-IT--Management
Joined
Mar 17, 2007
Messages
3
Location
GB
Hi,

I have a text file that contains, web addresses such as ' etc one per line.

I need to get a perl script that will scan through this text file and tell me the percentage of domains listed that end in either .co.uk or .com

Any hlp would be greatly appreciated.
 
Hi,

At the moment i don;t have anything was really just getting some idea son how to start and were best to start with this.

Thanks.
 
Ok, so far i have the following,

#!/usr/bin/perl -w

#Perl Script To Scan A Text File And Record The Percentage Of Domains Ending In .co.uk or .com

sub address()
{
$str=$_[0];
if($str=~m/\.co.uk\.com\Z/)
{
return 1;
}
return 0;
}
if( &address("\.co.uk\.com") == 1)
{
print "Valid Address\n"
}


how do this look for a base structure, where should i go form here?
 
if you want to figure percentage obviously you will need to count things. Incremet a scalar each time you find a domain that matches, and increment another scalar that is just the total number. Then do the math.

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
This question has been well answered on another forum so don't post any replies here unless you really want to.

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top