Short answer: yes!

Do you really need 253 configuration files with predictable name/contents mapping? If these files are required by an external tool to set the IP, then it would be smarter to generate a temporary config file on demand by the Perl program.

Furthermore, some questions to ask (yourself) to improve your specification:

Because, it's Sunday, here's a template to fiddle with... ;-)

use strict; use warnings; use constant { START_IP_BYTE4 => 2, MAX_IP_BYTE4 => 254, SLEEP => 12 * 3600 }; my @ip = qw(192 168 10 2); $ip[3] = shift || START_IP_BYTE4; while ( 'true' ) { set_ip( @ip ); $ip[3]++; $ip[3] = START_IP_BYTE4 if $ip[3] > MAX_IP_BYTE4; print "Next change: " . localtime( time() + SLEEP ) . "\n"; sleep SLEEP; # floating! } die "oops! $! / $@"; sub set_ip { my @ip = @_; my $ip = join( '.', @ip ); print "Setting local IP to $ip...\n"; print "Load file 'ip$ip[3].txt' ???\n"; #TODO: set local IP }

CPAN-search-terms-of-interest: cron, daemon, ifconfig, ...


In reply to Re: Is it possible to take the IP address from a file and assign it to LAN interface for certain period of time by Perlbotics
in thread Is it possible to take the IP address from a file and assign it to LAN interface for certain period of time by TechUser245

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.