[mrtg-developers] Re: PERLish cfgmaker question

Todd Caine todd_caine at eli.net
Tue Aug 5 02:29:04 MEST 2003


Charles,

On (Mon, Aug 04 19:01), Charles Johnson wrote:
> I can change the -1 to 500 with:
> 
> $config=~s/-1/500/;
> 
> What I'd really like to do is change either -1 or 0 in the MaxBytes 
> line to 500 with one statement.

$config =~ s/(?:-1|0)$/500/m;

You should probably make sure you are changing the MaxBytes line instead of the first -1 or 0 that you encounter.

e.g.:

my $config=<<'MRTG_CONFIG';
...
MaxBytes[kontor.cpu]: -1
...
MRTG_CONFIG

$config =~ s/(MaxBytes[^:]+:) (?:-1|0)$/$1 500/m;

This should print:
MaxBytes[kontor.cpu]: 500

HTH,
Todd

--
Unsubscribe mailto:mrtg-developers-request at list.ee.ethz.ch?subject=unsubscribe
Help        mailto:mrtg-developers-request at list.ee.ethz.ch?subject=help
Archive     http://www.ee.ethz.ch/~slist/mrtg-developers



More information about the mrtg-developers mailing list