Print Subject without characters Just Numbers using POP3Client. Please Help

E

eng.john84

I`m using POP3Client,
I don`t need to print all subject i need to print just number.
i.e --> if Subject: John 1234567890, Then i need to print 1234567890


use Mail::pOP3Client;


$pop = new Mail::pOP3Client( USER => "xxxxxxxxxxxxxxxxx",
PASSWORD => "xxxxxxxxxx",
HOST => "xxxxxxxxxx" );

for ($i = 1; $i <= $pop->Count(); $i++) {
foreach ( $pop->Head( $i ) ) {
/^(From|Subject):\s+/i and print $_, "\n";
}
print "\n";
sleep 5;
}
 
S

Sisyphus

I`m using POP3Client,
I don`t need to print all subject i need to print just number.
i.e --> if Subject: John 1234567890, Then i need to print 1234567890

I don't understand - there is usually *no* number associated with the
Subject. At least that's the way it is for me when I run the script you
provided. Typical output is:
 
S

Sisyphus

I`m using POP3Client,
I don`t need to print all subject i need to print just number.
i.e --> if Subject: John 1234567890, Then i need to print 1234567890

I don't understand - there is usually *no* number associated with the
Subject. At least that's the way it is for me when I run the script you
provided. Typical output is:
 
O

odhiseo

I don't understand - there is usually *no* number associated with the
Subject. At least that's the way it is for me when I run the script you
provided. Typical output is:


Maybe you want the Message-ID:

use Mail::pOP3Client;

$pop = new Mail::pOP3Client( USER => "xxxxxxxxxxxxxxxxx",
PASSWORD => "xxxxxxxxxx",
HOST => "xxxxxxxxxx" );

for ($i = 1; $i <= $pop->Count(); $i++) {
foreach ( $pop->Head( $i ) ) {
/^(Message-ID):\s+/i && print $_, "\n";
}
print "\n";
sleep 5;
}
 
O

odhiseo

Maybe you want the Message-ID:

use Mail::pOP3Client;

$pop = new Mail::pOP3Client( USER => "xxxxxxxxxxxxxxxxx",
PASSWORD => "xxxxxxxxxx",
HOST => "xxxxxxxxxx" );

for ($i = 1; $i <= $pop->Count(); $i++) {
foreach ( $pop->Head( $i ) ) {
/^(Message-ID):\s+/i && print $_, "\n";
}
print "\n";
sleep 5;
}

Sorry, now I understood your question

use Mail::pOP3Client;

$pop = new Mail::pOP3Client( USER => "xxxxxxxxxxxxxxxxx",
PASSWORD => "xxxxxxxxxx",
HOST => "xxxxxxxxxx" );

for ($i = 1; $i <= $pop->Count(); $i++) {
foreach ( $pop->Head( $i ) ) {
/^Subject:\.+\s(\d+)/i && print $1, "\n";
}
print "\n";
sleep 5;
}
 
O

odhiseo

Sorry, now I understood your question

use Mail::pOP3Client;

$pop = new Mail::pOP3Client( USER => "xxxxxxxxxxxxxxxxx",
PASSWORD => "xxxxxxxxxx",
HOST => "xxxxxxxxxx" );

for ($i = 1; $i <= $pop->Count(); $i++) {
foreach ( $pop->Head( $i ) ) {
/^Subject:\.+\s(\d+)/i && print $1, "\n";
}
print "\n";
sleep 5;
}- Hide quoted text -

- Show quoted text -

Here is another way to do It (TMTOWTDI)


use Mail::pOP3Client;

my $n = 10; #Length of number string in the subject


$pop = new Mail::pOP3Client( USER => "xxxxxxxxxxxxxxxxx",
PASSWORD => "xxxxxxxxxx",
HOST => "xxxxxxxxxx" );

for ($i = 1; $i <= $pop->Count(); $i++) {
foreach ( $pop->Head( $i ) ) {

next unless /^Subject:/;
/\s(\d{$n})(\s|$)/;
print $1;
}
print "\n";
sleep 5;
}

And in the previous reply I had a little error, you must change:
/^Subject:\.+\s(\d+)/i && print $1, "\n";
for:
/^Subject:.+\s(\d+)/i && print $1, "\n";
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top