Extract Email Address
am 15.11.2007 23:56:43 von M
I am writing some house keeping scripts for my email server. I wrote the
following to extract email address from string.
my $imap_pos = rindex($mailfile, "imap");
my $maildir_pos = rindex($mailfile, "Maildir");
my $user_string = substr($mailfile, $imap_pos+5, $maildir_pos-$imap_pos-6);
my $slash_pos = rindex($user_string, "/");
my $domain = substr($user_string, 0, $slash_pos);
my $user_name = substr($user_string, $slash_pos+1, 40);
my $email_account = "$user_name"."\@"."$domain\n";
$Mailfile basically looks like this.
/home/accountname/imap/some_domain_name_.net/username/Maildi r/new/
Can someone point me in a neater way to do this? This works fine though.
M
Re: Extract Email Address
am 16.11.2007 00:33:24 von glex_no-spam
M wrote:
> I am writing some house keeping scripts for my email server. I wrote the
> following to extract email address from string.
>
> my $imap_pos = rindex($mailfile, "imap");
> my $maildir_pos = rindex($mailfile, "Maildir");
> my $user_string = substr($mailfile, $imap_pos+5, $maildir_pos-$imap_pos-6);
> my $slash_pos = rindex($user_string, "/");
> my $domain = substr($user_string, 0, $slash_pos);
> my $user_name = substr($user_string, $slash_pos+1, 40);
> my $email_account = "$user_name"."\@"."$domain\n";
>
> $Mailfile basically looks like this.
>
> /home/accountname/imap/some_domain_name_.net/username/Maildi r/new/
>
> Can someone point me in a neater way to do this? This works fine though.
>
> M
>
>
my ($domain, $username ) = (split /\//, $mailfile) [4,5];
my $email_account = $username . '@' . $domain;
Re: Extract Email Address
am 16.11.2007 03:33:12 von krahnj
M wrote:
>
> I am writing some house keeping scripts for my email server. I wrote the
> following to extract email address from string.
>
> my $imap_pos = rindex($mailfile, "imap");
> my $maildir_pos = rindex($mailfile, "Maildir");
> my $user_string = substr($mailfile, $imap_pos+5, $maildir_pos-$imap_pos-6);
> my $slash_pos = rindex($user_string, "/");
> my $domain = substr($user_string, 0, $slash_pos);
> my $user_name = substr($user_string, $slash_pos+1, 40);
> my $email_account = "$user_name"."\@"."$domain\n";
>
> $Mailfile basically looks like this.
>
> /home/accountname/imap/some_domain_name_.net/username/Maildi r/new/
>
> Can someone point me in a neater way to do this? This works fine though.
my ( $user_string ) = $mailfile =~ m!imap/(.+?)/Maildir!;
my $email_account = join( '@', ( $user_string =~ m!(.+)/(.+)! )[ 1, 0 ]
) . "\n";
John
--
use Perl;
program
fulfillment