RegEx...

W

wizgod

To All hello. I am trying to grab a specific portion of the e-mail
address from
a string on the fly and for some reason It's(That is perl is not liking
what ever I Do.) I would appreciate your guidance oh great perl gurus
of the internet....:)

my $messageid = ( $string =~ m{Message-ID:
\<[email protected]>});
^^^^^^^^^^^^---This is
what I want.
But for some reason everything I try just will not work. This has to
happen this way as I'm doing someother processing on the fly with
string and what feeds
string isn't actually available for very long if you know what I mean.
Any Help would be great.

Jim,
 
B

Brian McCauley

To All hello. I am trying to grab a specific portion of the e-mail
address from a string on the fly and...

The exact syntax of email addresses is far from simple. There are
modules on CPAN to parse them.

my $messageid = ( $string =~ m{Message-ID:
\<[email protected]>});
^^^^^^^^^^^^---This is
what I want.

You apper to be mixing up your program and your data. Please produce a
minimal but complete script that you have actually run and which
illustrates the problem you are having.

Note also that the m// operator only returns the list of captures in a
list context but you don't capture anything.
But for some reason everything I try just will not work.

"not work" is a red flag phrase.

When ever you find yourself typing it you should immediately delete it
and replace it with a description of what happend.
This has to
happen this way as I'm doing someother processing on the fly with
string and what feeds
string isn't actually available for very long if you know what I mean.

No, I have absolutely no idea what you mean. What has to happen in what
way?
Any Help would be great.

Please see the posting guidelines. Hope that helps.
 
T

terry l. ridder

To All hello. I am trying to grab a specific portion of the e-mail
address from

first off, the message-id is not an e-mail address. message-id is a
globally unique identifier for that particular message.
a string on the fly and for some reason It's(That is perl is not liking
what ever I Do.) I would appreciate your guidance oh great perl gurus
of the internet....:)

my $messageid = ( $string =~ m{Message-ID:
\<[email protected]>});
^^^^^^^^^^^^---This is
what I want.

it is not clear to me what you want.
it would appear that you are search for one specific message-id.
 
A

A. Sinan Unur

To All hello. I am trying to grab a specific portion of the e-mail
address from a string on the fly and for some reason It's (That is
perl is not liking what ever I Do.) I would appreciate your guidance
oh great perl gurus of the internet....:)

The guidance you seek is provided in the posting guidelines for this
group. Please read them.
my $messageid = ( $string =~ m{Message-ID:
\<[email protected]>});
^^^^^^^^^^^^---This is
what I want.
But for some reason everything I try just will not work.


It looks like you have neither

use strict;

nor

use warnings;

in your script.

#! /usr/bin/perl

use strict;
use warnings;

my $s = q{Message-ID:\<[email protected]};

my $msg_id = ( $s =~ m{Message-ID:\<[email protected]>});
__END__

C:\Dload> q
Possible unintended interpolation of @news in string at C:\Dload\q.pl
line 8. Global symbol "@news" requires explicit package name at
C:\Dload\q.pl line 8. Execution of C:\Dload\q.pl aborted due to
compilation errors.

Also, I am not sure why you are escaping <.

Sinan.
 
T

Tore Aursand

To All hello. I am trying to grab a specific portion of the e-mail
address from
a string on the fly and for some reason It's(That is perl is not liking
what ever I Do.) I would appreciate your guidance oh great perl gurus
of the internet....:)

my $messageid = ( $string =~ m{Message-ID:
\<[email protected]>});
^^^^^^^^^^^^---This is
what I want.

Use the 'Mail::Address' module from CPAN. From the top of my head, it
works something like this;

#!/usr/bin/perl
#
use strict;
use warnings;
use Mail::Address;

my $string = 'Message-ID: <[email protected]>';
my @addresses = Mail::Address->parse( $string );

foreach ( @addresses ) {
print $_->user() . "\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

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top