I'm not clear what you mean about the regex's.
They tend to be portable to different locale's (well, within reason ...). For example:
\d - matches 0 .. 9 (\d+) - means match at least 1 digit, could be more. [^ ] - means don't match space \S - Another way to match something that isn't a space
And so on are universal. It is a vast area and easy to get lost in. But absolutely invaluable for data parsing. Baby steps and you will indeed get there! OK - so the postcode isn't in a predictable place. I assume it is in a predictable format that won't match anything else in a record?
e.g 2 upper case chars, followed by 3 digits and 2 further upper case chars. Then your regex:
$line =~ /,?([A-Z]{3}\d{2}[A-Z]),/;
The ',?' bit means maybe match a comma ahead of the postcode. This is to catch the case that the pc is at the start of the record.
$1 will contain your postcode.
If you pass me the format I'd be happy to provide a suitable regex.

In reply to Re^3: Parsing/manipulating CSV files by mrstlee
in thread Parsing/manipulating CSV files by Ansi

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.