in reply to Re: Re: Can I copy a file and rename the file to many new files?
in thread Can I copy a file and rename the file to many new files?

If you want to replace all occurances of HOST and IP in your mainfile.txt during the copy process, you just need to replace the printing part:

... foreach my $txt (@lines) { # replace HOST and IP with $hostname and $ipaddr $txt =~ s/HOST/$hostname/g; $txt =~ s/IP/$ipaddr/g; print $output "$txt\n"; }
This will replace ALL occurances of HOST and IP in your mainfile.txt.
  • Comment on Re: Re: Re: Can I copy a file and rename the file to many new files?
  • Download Code

Replies are listed 'Best First'.
Re: Re: Re: Re: Can I copy a file and rename the file to many new files?
by Anonymous Monk on Sep 29, 2003 at 17:36 UTC
    Hello

    Thank you very much for all your help.


    //Anders Andersson
Re: Re: Re: Re: Can I copy a file and rename the file to many new files?
by Anonymous Monk on Oct 01, 2003 at 14:02 UTC
    Hello

    I must ask you again about this script.
    I was trying this script but every file that are being created have the same info in it.

    These files have been created.
    mainfile_host1.txt
    mainfile_host2.txt

    Both of these file contain this info.
    someinfo
    host1
    192.168.1.1
    someinfo
    This is my computer host1 and it has the adress 192.168.1.1 someinfo someinfohost1someinfo

    I want the the file mainfile_host2.txt contain this info.
    someinfo
    host2
    192.168.1.2
    someinfo
    This is my computer host2 and it has the adress 192.168.1.2 someinfo someinfohost2someinfo

    But it want do that.


    //Anders Andersson