For the first part, you can use map (which takes a list of elements and returns a new one computed from elements of the first) and regexes

@xlinkpaths = map { if (/xlink (.+?) /) # if xlink has been found, and characters +captured { $1; } # yield the captured data else { (); } # yield 0 elements } @xlinks; # Do this for all elements of @xlinks
I'm aware that it's not the exact solution to your problem, you'll have to try to understand enough for you to correct it.

To concatenate two arrays (in the order you gave), just do: @exclpaths = (@xlinkpaths, @exclpaths);, or unshift @exclpaths, @xlinkpaths;, whatever looks clearer to you (if your lists are not really big, both are equivalent). See unshift or push.

In my $xlink,@xlinkpaths; the variable @xlinkpaths is not affected by the my, which will give you an error if you use strict (using strict will tell you where most of your mistakes are, so you should do it).


In reply to Re: Perl: Split/format the output and append it to an array by Eily
in thread Perl: Split/format the output and append it to an array by sravs448

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.