異なるドメインからの異なる電子メール ID を含むファイルから読み取る Perl プログラム。そして、ドメイン部分を削除してユーザー名をリストします。
例:
入力ファイルには次が含まれます。
abc@gmail.com
xyz@yahoo.com
pqr@test.com
出力ファイルは次のようになります。
The domain gmail.com contains following userid:
abc
The domain yahoo.com contains following userid:
xyz
The domain test.com contains following userid:
pqr
コードを使用してみましたが、ドメインとユーザー名が分離されているだけで、ドメイン名に従ってユーザー名がリストされていません。
use strict;
print "Enter the file name where emailids of different domains are present\n";
my $file=<stdin>;
open(DATA, "$file") or die ("Could not open the file\n");
while(<DATA>){
my @field=split(/@/, "$_" );
chomp $_;
my $username=@field[0];
my $domain=@field[1];
print "The user id is $username \nThe domain name is $domain \n";
}
close (DATA);