my $datafile = '/etc/postfix/virtual'; my $req_addr = "$username\@$domain"; my ( $name, $domain ) = $req_addr =~ /^([\w.-]+)(@[\w.-]+)$/ ; open FH, $datafile or die; my @virtual = ; close FH ; open FH, ">$datafile" or die; my $wrote_it = 0 ; for ( @virtual ) { print FH $_ ; if ( $_ =~ /$domain/ && !$wrote_it ) { print FH "$req_addr\t$username\n" ; $wrote_it++ ; } } close FH ; #### test.com VIRTUALDOMAIN #defines the domain name @test.com jnapier #defines the postmaster of domain idunno@test.com idunno #just a regular user other.com VIRTUALDOMAIN #defines the domain name @other.com jnapier #defines the postmaster of domain iknow@other.com iknow #just a regular user