in reply to Re: Perl: Split/format the output and append it to an array
in thread Perl: Split/format the output and append it to an array
For the most part if you find yourself writing significant code in a map, use a for loop instead. Your 7 line confusing map requiring multiple comments becomes:
for my $xlink (@xlinks) { push @xlinkpaths, $1 if $xlink =~ /xlink (.+?) /; }
Although you could instead write it:
@xlinkpaths = map {/xlink (.+?) / ? $1 : ()} @xlinks;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Perl: Split/format the output and append it to an array
by Anonymous Monk on Sep 11, 2014 at 22:14 UTC | |
|
Re^3: Perl: Split/format the output and append it to an array
by Eily (Monsignor) on Sep 12, 2014 at 07:21 UTC |