in reply to regex substitute(resolved)

Seems $1 was reset after every matching.

Correct. The pragma use warnings would tell you:

Use of uninitialized value $1 in substitution iterator at...

which indicates that $1 is undef, because nothing has been captured in the current substitution. Easily fixed by adding parentheses to capture the text you want to keep:

$ou =~ s/^\s*#\s*(PATH=.*\$NAS_DB\/bin.*)$/$1/;

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

Replies are listed 'Best First'.
Re^2: regex substitute(resolved)
by anaconda_wly (Scribe) on May 16, 2013 at 04:26 UTC
    Yes, fine. Thank you!