in reply to Yet another config file editing programme : Tell me how to make it better !

After a quick look at your code: how about removing comments before processing?

I think that's a must because you do allow comments (in your examples), but then you do when ( /interface/ ) { which will match a commented-out interface line or anything really that mentions the word "interface".

What I usually do for removing comment lines is $line =~ s/#.*$//; next if $line =~ /^\s*$/;

Secondly, if your grammar will grow then you are better off using other solutions, which other Monks I am sure will mention.

bw, bliako

Replies are listed 'Best First'.
Re^2: Yet another config file editing programme : Tell me how to make it better !
by dazz (Beadle) on Sep 02, 2021 at 08:22 UTC
    Hi
    Thanks for your feedback.

    The input file is machine generated so the content and format is well defined. The regex is loose.
    The output config file could be hand edited and so the regex is a lot more restrictive. Comments are ignored.

    I am hoping to be shown a better way of doing this.

    Dazz