Hi, Im now trying to generate a set of IP addresses, from 192.168.0.1, 192.168.0.2....upto 192.168.0.254 and then 192.168.1.1, 192.168.1.2 etc upt 192.168.1.254 and so on. I used the split command but for some reason am unable to transition from 192.168.0.254 to 192.168.1.1. Any help would be appreciated. Here is the code
print ("Enter the number of XML files required to be created:"); $number=<STDIN>; print ("\nEnter the name of the XML file:"); $file_name=<STDIN>; chomp($file_name); $xml=".xml"; $" = ':'; for ($i=1; $i<=$number; $i++) { $files="$file_name$i$xml"; open(FILE, ">$files") or die "Can't open the file: $i\n"; $first="SCS"; $leading = sprintf("%07d", $i); $firstname="$first$leading"; print FILE "\n <firstname>$firstname</firstname> "; $mac = sprintf("%012d", $i); @split = ($mac =~ /../g); $ip=sprintf("192168%06d",$i); @splitip= ($ip =~ /.../g); @splitipfinal= join('.', @splitip) . "\n"; print FILE "\n <name>NEW - @split</name> "; print FILE "\n <ipaddress>@splitipfinal</ipaddress> "; } print "\nThe XMLs have been created, check in the same directory!!";
And Prasad, sorry if I asked. Ive got a ton to do, in a short period of time, with my limited knowledge of perl. I always try before I ask. Thanks anyways... The next time you see me around, dont bother ok!

In reply to IP address generation by imperl

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.