[Perl Tk] Get IP 0.1

Iniciado por BigBear, Marzo 31, 2012, 09:06:05 PM

Tema anterior - Siguiente tema

0 Miembros y 1 Visitante están viendo este tema.

Marzo 31, 2012, 09:06:05 PM Ultima modificación: Marzo 14, 2015, 10:17:56 AM por Expermicid
Estaba muriendome de aburrimiento y me programe este pequeño programa en 5 minutos , que sirve para obtener la IP de un Host cualquiera.

Una imagen


El codigo

Código: perl

#!usr/bin/perl
#Get IP 0.1
#Version Tk
#Coded By Doddy H

use Tk;
use IO::Socket;

my $color_fondo = "black";
my $color_texto = "yellow";

if ( $^O eq 'MSWin32' ) {
    use Win32::Console;
    Win32::Console::Free();
}

my $ua =
  MainWindow->new( -background => $color_fondo, -foreground => $color_texto );
$ua->title("Get IP || Coded By Doddy H");
$ua->geometry("350x110+20+20");
$ua->resizable( 0, 0 );

$ua->Label(
    -text       => "Host : ",
    -font       => "Impact",
    -background => $color_fondo,
    -foreground => $color_texto
)->place( -y => 20, -x => 20 );
my $host = $ua->Entry(
    -width      => 30,
    -background => $color_fondo,
    -foreground => $color_texto
)->place( -y => 25, -x => 70 );
$ua->Button(
    -text             => "Get IP",
    -width            => 10,
    -command          => \&quien,
    -background       => $color_fondo,
    -foreground       => $color_texto,
    -activebackground => $color_texto
)->place( -y => 23, -x => 260 );

$ua->Label(
    -text       => "IP : ",
    -font       => "Impact",
    -background => $color_fondo,
    -foreground => $color_texto
)->place( -y => 60, -x => 20 );
my $ip = $ua->Entry(
    -width      => 33,
    -background => $color_fondo,
    -foreground => $color_texto
)->place( -y => 65, -x => 52 );

MainLoop;

sub quien {
    $ip->configure( -text => get_ip( $host->get ) );
}

sub get_ip {
    my $get = gethostbyname( $_[0] );
    return inet_ntoa($get);
}

#The End ?