in reply to Perl: Split/format the output and append it to an array
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).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Perl: Split/format the output and append it to an array
by GrandFather (Saint) on Sep 11, 2014 at 21:55 UTC | |
by Anonymous Monk on Sep 11, 2014 at 22:14 UTC | |
by Eily (Monsignor) on Sep 12, 2014 at 07:21 UTC | |
|
Re^2: Perl: Split/format the output and append it to an array
by einhverfr (Friar) on Sep 15, 2014 at 04:45 UTC |