#!/usr/bin/perl use strict; #use AnyDBM_File; # note, you may need to change this to "DB_File" use GDBM_File; # note, you may need to change this to "DB_File" use File::Find; my $homesdir = $ARGV[0]; my $usage = "Usage: $0 \n"; die "$usage" unless ($homesdir); my $account =""; my $oldaddress = ""; my $user = ""; my $host = ""; my $newhost ="mydomain.com"; my %db= (); find(\&wanted, $homesdir); sub wanted { return 0 unless ($File::Find::name =~ /userdb$/); unless (dbmopen %db, $File::Find::name ,undef) { warn "Could not open <$File::Find::name>: $! $@"; next; } $oldaddress = $db{"options.email"}; my $dir = $File::Find::dir; $dir =~ s#^.*/##; $oldaddress ||= $dir; print " old email: $oldaddress\n"; ($user,$host) = split(/@/, $oldaddress); my $newaddress = $user . '@' . $newhost; $db{"options.email"} = $newaddress; print " new email: $db{'options.email'}\n"; dbmclose %db; }