Hello, solocazzimiei and welcome to the Monastery. It is quite difficult to read your code in this post and it would help considerably if you could enclose each section of code within <code>...</code> tags.
While it is not entirely clear what you actually want here, you can use many techniques to separate a key from a value based upon the first colon. Since you are using a regex anyway, here is one such.
use strict;
use warnings;
use Test::More tests => 2;
my $in = "NOTE;ENCODING=QUOTED-PRINTABLE:=0AAddress:=0A=0Aor. Soroca=0
+ARepublic of Moldova=0A=0A=0A=0A Footwear. =Children's footwear. Lady
+'s footwear.";
my $want_key = 'NOTE;ENCODING=QUOTED-PRINTABLE';
my $want_value = "=0AAddress:=0A=0Aor. Soroca=0ARepublic of Moldova=0A
+=0A=0A=0A Footwear. =Children's footwear. Lady's footwear.";
$in =~ /^([^:]+):(.*)/;
is $1, $want_key, 'Key matches';
is $2, $want_value, 'Value matches';
Equally, you could use split or even index and substr to achieve the same end.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|