You obviously don't really understand split. Follow the link and look it up.

split is aimed at splitting a string into a list of parts, in order to later use these parts. Usually, the first parameter of split is the separator on which you want to break up the string (although the separator can be a bit more complicated than a simple character). You could certainly use split on your problem (as a part of the solution), it is probably not the best tool for your task. A simple regex is probably better.

One possible way to get the sender:

my $sender = $1 if /sender=(\S+)/;
This captures a string of as many characters other than spaces as possible following the "sender=" string in the $_ variable.

Update: I have never actually seen any problem with this syntax, but I have read several times and AnomalousMonk reminds me that conditionally defining lexicals can lead to unexpected results. Perhaps it is better to write:

my $sender; $sender = $1 if /sender=(\S+)/; if (defined $sender) { # ...
or possibly:
if (/sender=(\S+)/) { my $sender = $1; do_something_with_sender(); }
Thanks, AnomalousMonk.

In reply to Re^3: Array of strings search by Laurent_R
in thread Array of strings search by maikelnight

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.