Hello, I meant to send this to a perl mailing list and sent it two sunmanagers sorry. But Incase anyone needs this though: bash-2.03# ./create.pl host.list > newhost.out #!/usr/bin/perl -nlw while (<>) { # safely remove a carriage return from the file chomp $_; next if ($_ eq ""); # bail out if the line is empty #next if ($line eq ""); #next if ($line eq "#"); if (/(.*)\b(\d+)-(\d+)\b(.*)/) { print "$1$_$4" for $2..$3; } else { print; } } exit; bash-2.03# If the line is "something, number-number, something" it iterates from the first number to the second one ($2..$3) printing the line for every number in the sequence (which is in $_). Otherwise it just prints the original line. Thanks "zsdc". before script(hoat.list): 111.111.111.1-25|DEPTA #DEPTB 222.222.222.50-60|DEPTB results(newhost.out): 111.111.111.1|DEPTA 111.111.111.2|DEPTA . . 111.111.111.25|DEPTA #DEPTB 222.222.222.50|DEPTB 222.222.222.51|DEPTB . . 222.222.222.60|DEPTB Rob -------Original Message------- From: rmck <rmckeever@earthlink.net> Sent: 08/20/03 12:58 PM To: sunmanagers@sunmanagers.org Subject: Script for IP's > > 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 _______________________________________________ sunmanagers mailing list sunmanagers@sunmanagers.org http://www.sunmanagers.org/mailman/listinfo/sunmanagers _______________________________________________ sunmanagers mailing list sunmanagers@sunmanagers.org http://www.sunmanagers.org/mailman/listinfo/sunmanagersReceived on Thu Aug 21 12:41:04 2003
This archive was generated by hypermail 2.1.8 : Thu Mar 03 2016 - 06:43:18 EST