in reply to Re^2: find element in array, then advance to next element
in thread find element in array, then advance to next element

You need list context to assign the capture(s) — note the parentheses around $ports:

my ($ports) = $args =~ m/-p\s+([-\d]+)/;

Otherwise (in scalar context), you'd get whether the regex matched (thus the 1).

Replies are listed 'Best First'.
Re^4: find element in array, then advance to next element
by kathys39 (Acolyte) on Dec 09, 2008 at 19:19 UTC
    that's it - so sorry I missed that. Works perfectly - thanks so much!
Re^4: find element in array, then advance to next element
by CountZero (Bishop) on Dec 09, 2008 at 20:24 UTC
    Of course!

    Note to self: only try to answer questions on a computer which has Perl installed so you can test what you write.

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James