$header=~s/\r+//g;
and then try parsing it
Also
You need not use /\nFrom:\s*(.*)/m
You can use /^From:\s*(.*)$/m ( 'm' treats every new line a full string individually)
I think you are getting a carriage return.
Julien Motch wrote:
Hi ,
I am again experiencing problem with regular expressions and how to
print them .My program retrieves some mail headers and the extract two
strings : the subject ($subject) and the sender of the mail ($who) .Then
the program has to print them .
Here is the programm :
#Print subject and sender for the unreaded mail
for($i=0;$i<$unreaded_mails;$i++){
$header = $pop->Head($last_mail +$i + 1);
my ($who) = $header =~ /\nFrom:\s*(.*)/m;
my ($subject) = $header =~ /\nSubject:\s*(.*)/m;
#Here is the strange line
print("$who");
print(" has sended to you an email whom subject is $subject\n");
}
As it is now ,the program does not print the message sender but if
instead of `print("$who")` I write a `print("$who\n")` the sender is
correctly written .
And if I write `print("$who\t")` only the half of the string is
displayed end ends up with a `<`.
I suppose the `<` and `>` characters in the sender name are responsible
of my problem as the subject is correctly displayed .
Would anyone know how to fix the problem ?
Thanks ,Julien
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]