Rmck wrote: > > Hello, 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 This should do what you want: while ( my $line = <> ) { next if $line =~ /^#/; # skip comments. if ( $line =~ s/(\d+-\d+)/%d/ ) { ( my $range = $1 ) =~ s/-/ .. /; printf $line, $_ for eval $range; } else { print; } } John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]