RegEx...

Discussion in 'Perl Misc' started by wizgod@yahoo.com, Jan 26, 2005.

  1. Guest

    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:
    \<>});
    ^^^^^^^^^^^^---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,
    , Jan 26, 2005
    #1
    1. Advertising

  2. wrote:

    > 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:
    > \<>});
    > ^^^^^^^^^^^^---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.
    Brian McCauley, Jan 26, 2005
    #2
    1. Advertising

  3. On Wed, 26 Jan 2005, wrote:

    > 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:
    > \<>});
    > ^^^^^^^^^^^^---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.

    > 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,
    >
    >


    --
    terry l. ridder ><>
    terry l. ridder, Jan 26, 2005
    #3
  4. "" <> wrote in
    news::

    > 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:
    > \<>});
    > ^^^^^^^^^^^^---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:\<};

    my $msg_id = ( $s =~ m{Message-ID:\<>});
    __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.
    A. Sinan Unur, Jan 26, 2005
    #4
  5. Tore Aursand Guest

    wrote:
    > 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:
    > \<>});
    > ^^^^^^^^^^^^---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: <>';
    my @addresses = Mail::Address->parse( $string );

    foreach ( @addresses ) {
    print $_->user() . "\n";
    }


    --
    Tore Aursand <>
    "I didn't have time to write a short letter, so I wrote a long one
    instead." (Mark Twain)
    Tore Aursand, Jan 26, 2005
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?SmViQnVzaGVsbA==?=

    Is ASP Validator Regex Engine Same As VS2003 Find Regex Engine?

    =?Utf-8?B?SmViQnVzaGVsbA==?=, Oct 22, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    697
    =?Utf-8?B?SmViQnVzaGVsbA==?=
    Oct 22, 2005
  2. Rick Venter

    perl regex to java regex

    Rick Venter, Oct 29, 2003, in forum: Java
    Replies:
    5
    Views:
    1,620
    Ant...
    Nov 6, 2003
  3. Replies:
    2
    Views:
    595
  4. Xah Lee
    Replies:
    1
    Views:
    938
    Ilias Lazaridis
    Sep 22, 2006
  5. Replies:
    3
    Views:
    748
    Reedick, Andrew
    Jul 1, 2008
Loading...

Share This Page