I have a program i'm working on that basically will automate a virtual machine post install + extending an lvm

i've got the code for the extending all working

now my clone server that will run this program has an ip and FQDN that i need to change

the program usage is as follows:

Usage: ./update-vm -i <IP_ADDRESS> -s <SERVER_NAME> -i [IP_ADDRESS] IP Address to change to, format: A.B.C.D -s [SERVER_NAME] Hostname to change to, format: foo.foo.com or f +oo.foo.foo.foo.com -h Show this text

i was trying to avoid using system or just one liner perl search/replaces for the IP and hostname strings to search for in /etc/ and change

my variables are $old_ip statically set in program, $old_name statically set in program, $new_ip gotten from ARGV and $new_name gotten from ARGV

I did read about Find::File and Find::Glob and File::Slurp but i cant find any really good examples that dont just try and do find or system calls which i would like to avoid for best practice reasons, plus the examples ive seen are calling from a file where im grabbing from user input from my Getops::Long

thanks in advance for your help monks!

if i can provide anymore information ill be happy to!


In reply to need to be able to search/replace by ip and hostname recursively in /etc based off ARG input by globalsec23

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.