Kerby82 Kerby82 - 1 year ago 67
Perl Question

How do I substitute a particular IP in a file with Perl?

I have a list of IPs, I have to transform all the lPs starting with


For example:

Is there any in-line Perl regular expression substitution to do that?

I would like to have this substitution in Perl.

Answer Source

why don't you use sed instead ?

sed -e 's/^210\./10./' yourfile.txt

If you really want a perl script :

while (<>) { $_ =~ s/^210\./10./; print }
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download