#!/usr/bin/perl
# random IP using join:
# First method:
$oct1 = int rand(254);
$oct2 = int rand(254);
$oct3 = int rand(254);
$oct4 = int rand(254);
$ip = join('.', $oct1, $oct2, $oct3, $oct4);
print "random ip: $ip\n";
# Second method:
$ip = join(".", map int rand 256, 1 .. 4);
print "random ip: $ip\n";
Showing posts with label perl join random ip. Show all posts
Showing posts with label perl join random ip. Show all posts
Saturday, April 26, 2008
Random IP generator
Here are two ways using 'join' to create random IP's:
Subscribe to:
Posts (Atom)