Script for IP's

2007-12-25 1:51:00

Hello,

I have a perl script that opens up a text file and displays the data fine.

My textfile:

111.111.111.1-25|DEPTA
222.222.222.50-60|DEPTB

What I would like to do is have it increment 1 through 25, and 50 through
60, and display that like so:

SO FAR ......
here is the data file hosts.dat:

111.111.111.444|DEPTA
# DEPTB Stuff
222.222.222.1-15|DEPTB
222.222.222.20|DEPTB
# DEPTC INFO
333.333.333.20-25|DEPTC
#
444.444.44.555|DEPTF

here is script "create.pl":

#!/usr/bin/perl -w

while (<>) {

next if /^#/; # skip comments.

if (/\b-\b/){

print;

}
}

bash-2.03# ./create.pl host.dat
222.222.222.1-15|DEPTB
333.333.333.20-25|DEPTC
bash-2.03#

WHAT I NEED...
So what im looking at doing is having IP's with "-" print out as so and to
a new file....:
222.222.222.1|DEPTB
222.222.222.2|DEPTB
.
.
222.222.222.15|DEPTB
333.333.333.20|DEPTC
333.333.333.21|DEPTC
.
.
333.333.333.25|DEPTC

Thanks up Front??

rob

Comments

Got something to say?

You must be logged in to post a comment.