G'day Geert,
++ You're asking good questions. :-)
You've received a lot of good answers, so I won't delve into those again. However, I did want to say something about abstraction.
Whenever you have code with many lines that are almost identical, consider abstracting that code into one or more subroutines. Here's an example:
my @inputpaths = @{test_paths([1..3])}; push @inputpaths, @{test_paths([4..7])}; sub test_paths { my ($ids) = @_; state $prefix = 'C:/Temp/xml/'; return [ map "${prefix}test${_}.xml", @$ids ]; }
That code is intended to give you an idea of abstraction based on what you originally posted.
In other scenarios, you might want to pass $prefix as an argument to give you more flexibility; and, unless all your filenames look like testN.xml, you'd probably want to do something different than passing a list of numbers (to replace N). I'd also recommend you heed the advice of ++haukex regarding the use of modules such as File::Spec.
— Ken
In reply to Re: Adding items to arrays: best approach?
by kcott
in thread Adding items to arrays: best approach?
by geertvc
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |