Re: How can I translate it back to @ sign.



On Thu, Jun 26, 2008 at 4:21 PM, Aruna Goke <myklass@xxxxxxxxx> wrote:
David Romero wrote:

use a regular expression

my $email = 'user!dominio.com';
$email =~ s/!/@/g;
###Result user@xxxxxxxxxxx

http://www.troubleshooters.com/codecorn/littperl/perlreg.htm


On Thu, Jun 26, 2008 at 1:35 PM, Aruna Goke <myklass@xxxxxxxxx> wrote:

hi,

i have the this log from my sms gateway, however, the inverted
exclamation
mark was sent from the smsc as @.

2008-06-26 17:22:35 SMS request sender:+2342019122 request:
'maruna¡ontng.com,test,Love my test message' file answer: ''
2008-06-26 17:27:17 Receive SMS [SMSC:caxt] [SVC:] [ACT:] [BINF:]
[from:+2342019122] [to:+2349191] [flags:-1:0:-1:0:-1]
[msg:43:maruna!ontng.com,test,Love my test message] [udh:0:]
2008-06-26 17:27:17 SMS request sender:+23422019122 request:
'maruna!ontng.com,test,'Love my test message'file answer: ''
2008-06-26 17:34:15 Receive SMS [SMSC:caxt] [SVC:] [ACT:] [BINF:]
[from:+2342019122] [to:+2349191] [flags:-1:0:-1:0:-1]
[msg:43:maruna¡ontng.com,test,Love my test message] [udh:0:]

I have my script that parse the file and extract as below

To: maruna¡ontng.com Subject: test Message: Love my test message sender
:
2342010012@xxxxxxxxx


What i want to achieve is to translate the to address back to
maruna@xxxxxxxxx instaed of maruna¡ontng.com.

when i checked through, i discover that it is inverted exclamation mark
with
character code 00A1 from unicode(hex) of latin-1 subset. I need this
translated to @, any help will be appreciated


my script is as below

#!/usr/bin/perl

use strict;
use warnings;
use File::Tail;
use Mail::Sender;


# the access.log is read and the following, recepient is extracted.

my $name = "/var/log/bulksms/sms_access.log";
my ($mailreci, $mailsubj, @sms, $mailmsg, $mailsend, $sendee, $sender,
$msg,
$domain);
$domain = 'ontng.com';
open my $file, '<', $name or die "could not open $name: $!";
$file=File::Tail->new(name=>$name, maxinterval=>3, adjustafter=>5);
while (defined($_=$file->read))
{
@sms = split/\[/;
next unless $sms[6]=~/to:\+2349191\]/;
$sendee = $sms[5];
$sendee =~ s/from:\+(\d+)\]/$1/;
$sendee = "$sendee\@$domain";
$msg = $sms[8];
$msg = (split/:/, $msg)[-1];
$msg =~ s/(\w+)\s?\]/$1/;
# i need only sender and $msg
($mailreci, $mailsubj, $mailmsg) = (split/,/, $msg, 3)[0..2];

print "To: $mailreci Subject: $mailsubj Message: $mailmsg sender :
$sendee\n";

}




--
To unsubscribe, e-mail: beginners-unsubscribe@xxxxxxxx
For additional commands, e-mail: beginners-help@xxxxxxxx
http://learn.perl.org/







its not an exclamation mark but inverted exclammation mark.

if your file is in utf-8 it is no problem

my $email = 'user¡dominio.com';
$email =~ s/¡/@/g;
###Result user@xxxxxxxxxxx

if the log file is in latin1 or other do a charset conversion first
http://search.cpan.org/~dankogai/Encode-2.25/Encode.pm





--
To unsubscribe, e-mail: beginners-unsubscribe@xxxxxxxx
For additional commands, e-mail: beginners-help@xxxxxxxx
http://learn.perl.org/






--
David Romero
www.factufacil.com.mx


Relevant Pages

  • Re: mutable default parameter problem [Prothon]
    ... IOW, say you have a ... It's not that the exclamation mark that causes append to ...
    (comp.lang.python)
  • Re: word icons
    ... I would imagine that the ones with exclamation points are macro-enabled Word ... file displayed the Word icon with either a green circle with a check mark ...
    (microsoft.public.word.docmanagement)
  • Re: OT on Orthography
    ... Is this a new trend? ... just a coincidence that I recently spotted the above in a few ... apostrophe (the "grimmest" mark), and I guess the exclamation point ...
    (alt.usage.english)
  • Re: OT on Orthography
    ... Is this a new trend? ... just a coincidence that I recently spotted the above in a few ... I have poems on the semi-colon (the "fairest" mark) and the ... and I guess the exclamation point ...
    (alt.usage.english)