[PLUG] Okay after awk I need....

Michael Rasmussen mikeraz at patch.com
Fri May 6 23:31:22 UTC 2005


techmage wrote:
> I'm taking a line separated list of Usernames and domain names and 
> removing the usernames(don't need them)
 
Assuming that the list looks like:

username	tire.patch.com
uname2	berry.patch.com
userthree	patch.com


#!/usr/bin/perl -w

# really should test this before blatting it out to plug
# but Randal or Ovid will quickly slap up a correction so 
# the community is safe

# just read the list from STDIN or filename on command line
# for laziness
while(<>) {
	chomp;
	($user, $domain) = split;
	if($domain) {
	  (@domain_parts) = split /\./, $domain;
	  print "$domain_parts[$#domain_parts-1].$domain_parts[$#domain_parts]\n";
	}
}

if the data comes from a list of email addresses then change 
	($user, $domain) = split;
to
	($user, $domain) = split /@/;

> Anyone feel like helping me or, having done this before, parcel thy 
> wisdom in my general direction.
 
> It's worth a beer and a copy of my Chili Verde recipe.

It's worth wiling away some time while waiting for the change control window to
open.


-- 
    Michael Rasmussen, Portland Oregon  
  Be appropriate && Follow your curiosity
 http://meme.patch.com/memes/BicycleRiding
   Get Fixed:  http://www.dampfixie.org
  The fortune cookie says:
The Pig, if I am not mistaken,
Gives us ham and pork and Bacon.
Let others think his heart is big,
I think it stupid of the Pig.
		-- Ogden Nash




More information about the PLUG mailing list