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



Hi Aruna

The solution


my $invexcl = "\x{00A1}";
my $atsign = "\x{0040}";
$mailreci =~ s/(\w+)$invexcl(\w+)/$1$atsign$2/g;

works fine.

However that assumes that you know the control character to be substituted.

If the file contains lots of control characters and if the requirement is to
remove all of them or to
substitute all of them with some ascii character etc, my solution is
preferred.

By the way, how do you find the octal / hexadecimal code of control
character that appears in the file.

I use UNIX "ob -bc" command for the same but even that is also cumbersome if
there are many lines
and many control charcters.

Regards,
Amit Saxena


On Mon, Jun 30, 2008 at 7:05 PM, Aruna Goke <myklass@xxxxxxxxx> wrote:

Amit Saxena wrote:

Try

$email =~ s/[[:cntrl:]]/@/g;

instead of

$email =~ s/!/@/g;

Infact try this in the entire file.

Note :- This is on the assumption that there are no other control
characters in the input file.

On Fri, Jun 27, 2008 at 2:51 AM, Aruna Goke <myklass@xxxxxxxxx <mailto:
myklass@xxxxxxxxx>> wrote:

David Romero wrote:

use a regular expression

my $email = 'user!dominio.com <http://dominio.com>';
$email =~ s/!/@/g;
###Result user@xxxxxxxxxxx <mailto:user@xxxxxxxxxxx>

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


On Thu, Jun 26, 2008 at 1:35 PM, Aruna Goke <myklass@xxxxxxxxx
<mailto: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 <http://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 <http://ontng.com>,test,Love my
test message] [udh:0:]
2008-06-26 17:27:17 SMS request sender:+23422019122 request:
'maruna!ontng.com <http://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 <http://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 <http://ontng.com> Subject: test
Message: Love my test message sender :
2342010012@xxxxxxxxx <mailto:2342010012@xxxxxxxxx>


What i want to achieve is to translate the to address back to
maruna@xxxxxxxxx <mailto:maruna@xxxxxxxxx> instaed of
maruna¡ontng.com <http://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 <http://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
<mailto:beginners-unsubscribe@xxxxxxxx>
For additional commands, e-mail: beginners-help@xxxxxxxx
<mailto:beginners-help@xxxxxxxx>
http://learn.perl.org/







its not an exclamation mark but inverted exclammation mark.




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




my $invexcl = "\x{00A1}";
my $atsign = "\x{0040}";
$mailreci =~ s/(\w+)$invexcl(\w+)/$1$atsign$2/g;

I have used that above code to do the conversion and it seems to work now..

Goksie





Relevant Pages

  • REVIEW/ACRA: Superfreaks # 9-13
    ... So, I finally got around to reading last month's batch of SUPERFREAKS, ... hard on Martin for the transparency of some of his character analogues. ... Now, during this, we get a personal B-plot with goofy Edward courting ... And that's control. ...
    (rec.arts.comics.creative)
  • Re: wide screen text mode?
    ... Is there a reason it *must* be DOS text mode? ... attribute color control. ... With a script or a long novel, each character can be assigned a custom ... pasted 4 such screens together to get a screen that is 1212x800. ...
    (comp.os.msdos.programmer)
  • Re: several simple questions about text boxes
    ... > I'm not the brightest MS Access user, so I need a little help. ... The answer depends on WHEN you need to get the length of the string. ... attempt to move off the control HAS NOT occurred. ... > Let's say I want to pull out the third character of any word, ...
    (microsoft.public.access.forms)
  • Re: Turnbased CRPG?
    ... >>TB CRPGs rely on player intelligence instead of reaction speed (i.e. the ... When it comes to tactical combat the ... control a party, the only way to really control them intelligently is ... I'm making the decisions for another character. ...
    (comp.sys.ibm.pc.games.rpg)
  • Re: Direct access to the UART?
    ... of them which I can control and the other which is absolutely out of my ... You may set-up the UART for the needed speed using the 16550 driver ... new character in the rx FIFO or when a character has been received. ... (l'indirizzo di reply di questo messaggio non è ...
    (microsoft.public.windowsce.platbuilder)