One more, kinda unrelated, point. In Perl, unlike say in C#, the foreach loop variable is an alias to the list element and MAY be modified. So there is no reason to bother with the indices:
for (@cmd) {
$_ = [split "\n", $_]->[0];
}
Next thing ... you don't have to create an anonymous reference and then dereference it to get the first element from a list returned by a subroutine. A pair of braces is enough:
for (@cmd) {
$_ = (split "\n", $_)[0];
}
And last there really is no reason to avoid regexps. They tend to make the code simpler.
for (@cmd) {
s/\n.*$//s;
}
Jenda
Enoch was right!
Enjoy the last years of Rome.