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
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.@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
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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |