10-21-2009, 01:43 PM
As always brought to you by my blog http://bsdpunk.blogspot.com:
For Mac:
For Linux:
If you want this broken down line by line, I do that here:
http://bsdpunk.blogspot.com/2009/07/perl...al-ip.html
For Mac:
PHP Code:
#!/opt/local/bin/perl
my @ifconfig = `ifconfig`;
my $inetter = qr/(inet \d+\.\d+\.\d+.\d+)/;
foreach (@ifconfig) {
my $line = $_;
if ($line =~ $inetter){
print $&."\n";
}
}
PHP Code:
#!/usr/bin/perl
my @ifconfig = `ifconfig`;
my $inetter = qr/(inet addr:\d+\.\d+\.\d+.\d+)/;
foreach (@ifconfig) {
my $line = $_;
if ($line =~ $inetter){
print $&."\n";
}
}
If you want this broken down line by line, I do that here:
http://bsdpunk.blogspot.com/2009/07/perl...al-ip.html