How can I improve this regex append?
<p>I have this perl command to append a new line and works, but, can it be improved?</p>

<pre><code>perl -p -i -e 's/^*.*normal_check_interval*.*5*.*$/\tnormal_check_interval\t\t5\n\tcheck_period\t\t\tmy_time_period/' file.cfg
</code></pre>

<p>For example I think that I can use something like:</p>

<pre><code>perl -p -i -e 's/^*.*normal_check_interval*.*5*.*$/\t$1\n\tcheck_period\t\t\tmy_time_period/' file.cfg
</code></pre>

<p>but I'm not sure about syntax</p>

<p>thanks in advance</p>

<hr>

<p>EDIT:
@Sobrique suggestion</p>

<p>It is for edit several nagios cfg files at once.</p>

<p>Example:</p>

<p>Before:</p>

<pre><code>service{

    ...
    normal_check_interval   5
    ...
}
</code></pre>

<p>After:</p>

<pre><code>service{

    ...
    normal_check_interval   5
    check_period            my_time_period
    ...
}
</code></pre>

<hr>

<p>Edit 2:</p>

<p>Based in @Borodin answer I finnaly got this:</p>

<pre><code>perl -p -i -e 's/^(\s+normal_check_interval\s+5)/$1\n\tcheck_period\t\t\tmy_time_period/' file
</code></pre>