Re: using a list
- From: "Lambik" <lambik@xxxxxxxxxx>
- Date: Tue, 27 Feb 2007 23:47:18 +0100
<corefile@xxxxxxxxx> wrote in message
news:1172614368.083420.209560@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Trying to create a way to create a list of ip's portDoes this code even run?
$ip = 192.168.100.1; #first ipI have no idea what this does. I guess you want "192.168.100.1"
$nip = 254; #number of ipsWhy this? It isn't used
@allports = ("25", "110", "443", "179"); #listening portsSame here.
$fip = 10.100.100.1; # static ip everything get forwarded to
$fport = 10001; # starting port that @allports will forward to running
on fip
$file = somefile.txt;
What's $n? Where is it declared.
for ( 1..$n ) {
$ip =~ s/\.(\d+)$/.$_/;
$fport = $fport++;
open (FD, ">>", $file);
printf (FD "$ip maps to $fip $fport\n");
close (FD);
}
I can't figure out how to implement the @allports part. As I'm a total
noob this is probably not the most efficient way but as long as it
work thats fine for me.
Does it? This code runs? Wow.
If I understand you correctly you want something like:
#!/usr/bin/perl
use warnings;
use strict;
my $ip = "192.168.100"; #first ip
my @allports = ("25", "110", "443", "179"); #listening ports
my $fip = "10.100.100.1"; # static ip everything get forwarded to
my $fport = 10001; # starting port that @allports will forward to running on
fip
my $file = "somefile.txt";
foreach my $port (@allports) {
open (FD, ">>", $file);
print FD "$ip.$port maps to $fip $fport\n";
close (FD);
$fport++;
}
.
- References:
- using a list
- From: corefile
- using a list
- Prev by Date: Re: Choosing the path based on the system "uname" command
- Next by Date: Re: Choosing the path based on the system "uname" command
- Previous by thread: Re: using a list
- Next by thread: sysread & eof
- Index(es):