• Willkommen im Linux Club - dem deutschsprachigen Supportforum für GNU/Linux. Registriere dich kostenlos, um alle Inhalte zu sehen und Fragen zu stellen.

Perl Programm soll interagieren mit sich selber auf 2 PCs

byron1778

Hacker
Hallo Forum,

ich habe womöglich eine etwas ausgefallene Frage.
Ich habe ein Perl Programm geschrieben mit Checkbuttons.
Sobald man eines dieser Checkbuttons aktiviert, soll "zeitgleich" auf einem anderen PC ebenso diese Checkbox als aktiviert vermerkt werden.

Kann mir jemand vielleicht sagen, unter welchen Stichwörtern ich da nachschauen kann bzw. ist so etwas überhaupt mit Perl möglich?

Weiters wäre es angenehm, wenn ich mir die angeklickten Checkboxen zählen lassen könnte und mir auf der Oberfläche ausgegeben wird?!

Hier einmal der Code.

Code:
#!/usr/bin/perl -w 

use Tk; 

my $mw = MainWindow -> new; 
$mw->title('Poker - Programm'); 
$mw->geometry("800x600+800+0");
$mw->Button(-text => "Pik As", -command => sub {  })->place(-relx => 0.1, -rely => 0.1); 
$mw->Button(-text => "Pik Koenig", -command => sub {  })->place(-relx => 0.1, -rely => 0.2); 
$mw->Button(-text => "Pik Dame", -command => sub {  })->place(-relx => 0.1, -rely => 0.3);  
$mw->Button(-text => "Pik Bube", -command => sub {  })->place(-relx => 0.1, -rely => 0.4);  
$mw->Button(-text => "Pik 10", -command =>  sub {  })->place(-relx => 0.1, -rely => 0.5);  
$mw->Button(-text => "Pik 9", -command =>  sub {  })->place(-relx => 0.1, -rely => 0.6); 
$mw->Button(-text => "Pik 8", -command =>  sub {  })->place(-relx => 0.1, -rely => 0.7);  
$mw->Button(-text => "Pik 7", -command =>  sub {  })->place(-relx => 0.1, -rely => 0.8); 
$mw->Button(-text => "Pik 6", -command =>  sub {  })->place(-relx => 0.1, -rely => 0.9); 
$mw->Button(-text => "Pik 5", -command =>  sub {  })->place(-relx => 0.2, -rely => 0.1); 
$mw->Button(-text => "Pik 4", -command =>  sub {  })->place(-relx => 0.2, -rely => 0.2); 
$mw->Button(-text => "Pik 3", -command =>  sub {  })->place(-relx => 0.2, -rely => 0.3); 
$mw->Button(-text => "Pik 2", -command =>  sub {  })->place(-relx => 0.2, -rely => 0.4); 

$mw->Button(-text => "Herz As", -command => sub {  })->place(-relx => 0.3, -rely => 0.1); 
$mw->Button(-text => "Herz Koenig", -command => sub {  })->place(-relx => 0.3, -rely => 0.2); 
$mw->Button(-text => "Herz Dame", -command => sub {  })->place(-relx => 0.3, -rely => 0.3);  
$mw->Button(-text => "Herz Bube", -command => sub {  })->place(-relx => 0.3, -rely => 0.4);  
$mw->Button(-text => "Herz 10", -command =>  sub {  })->place(-relx => 0.3, -rely => 0.5);  
$mw->Button(-text => "Herz 9", -command =>  sub {  })->place(-relx => 0.3, -rely => 0.6); 
$mw->Button(-text => "Herz 8", -command =>  sub {  })->place(-relx => 0.3, -rely => 0.7);  
$mw->Button(-text => "Herz 7", -command =>  sub {  })->place(-relx => 0.3, -rely => 0.8); 
$mw->Button(-text => "Herz 6", -command =>  sub {  })->place(-relx => 0.3, -rely => 0.9); 
$mw->Button(-text => "Herz 5", -command =>  sub {  })->place(-relx => 0.4, -rely => 0.1); 
$mw->Button(-text => "Herz 4", -command =>  sub {  })->place(-relx => 0.4, -rely => 0.2); 
$mw->Button(-text => "Herz 3", -command =>  sub {  })->place(-relx => 0.4, -rely => 0.3); 
$mw->Button(-text => "Herz 2", -command =>  sub {  })->place(-relx => 0.4, -rely => 0.4);

$mw->Button(-text => "Treff As", -command => sub { })->place(-relx => 0.5, -rely => 0.1); 
$mw->Button(-text => "Treff Koenig", -command => sub {  })->place(-relx => 0.5, -rely => 0.2); 
$mw->Button(-text => "Treff Dame", -command => sub {  })->place(-relx => 0.5, -rely => 0.3);  
$mw->Button(-text => "Treff Bube", -command => sub {  })->place(-relx => 0.5, -rely => 0.4);  
$mw->Button(-text => "Treff 10", -command =>  sub {  })->place(-relx => 0.5, -rely => 0.5);  
$mw->Button(-text => "Treff 9", -command =>  sub {  })->place(-relx => 0.5, -rely => 0.6); 
$mw->Button(-text => "Treff 8", -command =>  sub {  })->place(-relx => 0.5, -rely => 0.7);  
$mw->Button(-text => "Treff 7", -command =>  sub {  })->place(-relx => 0.5, -rely => 0.8); 
$mw->Button(-text => "Treff 6", -command =>  sub {  })->place(-relx => 0.5, -rely => 0.9); 
$mw->Button(-text => "Treff 5", -command =>  sub {  })->place(-relx => 0.6, -rely => 0.1); 
$mw->Button(-text => "Treff 4", -command =>  sub {  })->place(-relx => 0.6, -rely => 0.2); 
$mw->Button(-text => "Treff 3", -command =>  sub {  })->place(-relx => 0.6, -rely => 0.3); 
$mw->Button(-text => "Treff 2", -command =>  sub {  })->place(-relx => 0.6, -rely => 0.4);

$mw->Button(-text => "Caro As", -command => sub {  })->place(-relx => 0.7, -rely => 0.1); 
$mw->Button(-text => "Caro Koenig", -command => sub {  })->place(-relx => 0.7, -rely => 0.2); 
$mw->Button(-text => "Caro Dame", -command => sub {  })->place(-relx => 0.7, -rely => 0.3);  
$mw->Button(-text => "Caro Bube", -command => sub {  })->place(-relx => 0.7, -rely => 0.4);  
$mw->Button(-text => "Caro 10", -command =>  sub {  })->place(-relx => 0.7, -rely => 0.5);  
$mw->Button(-text => "Caro 9", -command =>  sub {  })->place(-relx => 0.7, -rely => 0.6); 
$mw->Button(-text => "Caro 8", -command =>  sub {  })->place(-relx => 0.7, -rely => 0.7);  
$mw->Button(-text => "Caro 7", -command =>  sub {  })->place(-relx => 0.7, -rely => 0.8); 
$mw->Button(-text => "Caro 6", -command =>  sub {  })->place(-relx => 0.7, -rely => 0.9); 
$mw->Button(-text => "Caro 5", -command =>  sub {  })->place(-relx => 0.8, -rely => 0.1); 
$mw->Button(-text => "Caro 4", -command =>  sub {  })->place(-relx => 0.8, -rely => 0.2); 
$mw->Button(-text => "Caro 3", -command =>  sub {  })->place(-relx => 0.8, -rely => 0.3); 
$mw->Button(-text => "Caro 2", -command =>  sub {  })->place(-relx => 0.8, -rely => 0.4);

$cb_value_0 = 0;
$cb_value = $mw -> Checkbutton(-variable => \$cb_value_0, -command => sub { $cb_value_0 = 1; })->place(-relx => 0.15, -rely => 0.1);

$cb_value_1 = 0;
$cb_value = $mw -> Checkbutton(-variable => \$cb_value_1, -command => sub { $cb_value_1 = 1 })->place(-relx => 0.15, -rely => 0.2);
$cb_value_2 = 0;
$cb_value = $mw -> Checkbutton(-variable => \$cb_value_2, -command => sub { $cb_value_2 = 1 })->place(-relx => 0.15, -rely => 0.3);
$cb_value_3 = 0;
$cb_value = $mw -> Checkbutton(-variable => \$cb_value_3, -command => sub { $cb_value_3 = 1 })->place(-relx => 0.15, -rely => 0.4);
$cb_value_4 = 0;
$cb_value = $mw -> Checkbutton(-variable => \$cb_value_4, -command => sub { $cb_value_4 = 1 })->place(-relx => 0.15, -rely => 0.5);
$cb_value_5 = 0;
$cb_value = $mw -> Checkbutton(-variable => \$cb_value_5, -command => sub { $cb_value_5= 1 })->place(-relx => 0.15, -rely => 0.6);
$cb_value_6 = 0;
$cb_value = $mw -> Checkbutton(-variable => \$cb_value_6, -command => sub { $cb_value_6 = 1 })->place(-relx => 0.15, -rely => 0.7);
$cb_value_7 = 0;
$cb_value = $mw -> Checkbutton(-variable => \$cb_value_7, -command => sub { $cb_value_7 = 1 })->place(-relx => 0.15, -rely => 0.8);
$cb_value_8 = 0;
$cb_value = $mw -> Checkbutton(-variable => \$cb_value_8, -command => sub { $cb_value_8= 1 })->place(-relx => 0.15, -rely => 0.9);
$cb_value_9 = 0;
$cb_value = $mw -> Checkbutton(-variable => \$cb_value_9, -command => sub { $cb_value_9 = 1 })->place(-relx => 0.25, -rely => 0.1);
$cb_value_10 = 0;
$cb_value = $mw -> Checkbutton(-variable => \$cb_value_10, -command => sub { $cb_value_10= 1 })->place(-relx => 0.25, -rely => 0.2);
$cb_value_11 = 0;
$cb_value = $mw -> Checkbutton(-variable => \$cb_value_11, -command => sub { $cb_value_11= 1 })->place(-relx => 0.25, -rely => 0.3);
$cb_value_12 = 0;
$cb_value = $mw -> Checkbutton(-variable => \$cb_value_12, -command => sub { $cb_value_12= 1 })->place(-relx => 0.25, -rely => 0.4);
$cb_value_13 = 0;
$cb_value= $mw -> Checkbutton(-variable => \$cb_value_13, -command => sub { $cb_value_13= 1 })->place(-relx => 0.35, -rely => 0.1);
$cb_value_14 = 0;
$cb_value= $mw -> Checkbutton(-variable => \$cb_value_14, -command => sub { $cb_value_14= 1 })->place(-relx => 0.35, -rely => 0.2);
$cb_value_15 = 0;
$cb_value= $mw -> Checkbutton(-variable => \$cb_value_15, -command => sub { $cb_value_15= 1 })->place(-relx => 0.35, -rely => 0.3);
$cb_value_16 = 0;
$cb_value= $mw -> Checkbutton(-variable => \$cb_value_16, -command => sub { $cb_value_16= 1 })->place(-relx => 0.35, -rely => 0.4);
$cb_value_17 = 0;
$cb_value= $mw -> Checkbutton(-variable => \$cb_value_17, -command => sub { $cb_value_17 = 1 })->place(-relx => 0.35, -rely => 0.5);
$cb_value_18 = 0;
$cb_value= $mw -> Checkbutton(-variable => \$cb_value_18, -command => sub { $cb_value_18= 1 })->place(-relx => 0.35, -rely => 0.6);
$cb_value_19 = 0;
$cb_value= $mw -> Checkbutton(-variable => \$cb_value_19, -command => sub { $cb_value_19= 1 })->place(-relx => 0.35, -rely => 0.7);
$cb_value_20 = 0;
$cb_value= $mw -> Checkbutton(-variable => \$cb_value_20, -command => sub { $cb_value_20 = 1 })->place(-relx => 0.35, -rely => 0.8);
$cb_value_21 = 0;
$cb_value= $mw -> Checkbutton(-variable => \$cb_value_21, -command => sub { $cb_value_21= 1 })->place(-relx => 0.35, -rely => 0.9);
$cb_value_22 = 0;
$cb_value= $mw -> Checkbutton(-variable => \$cb_value_22, -command => sub { $cb_value_22= 1 })->place(-relx => 0.45, -rely => 0.1);
$cb_value_23 = 0;
$cb_value= $mw -> Checkbutton(-variable => \$cb_value_23, -command => sub { $cb_value_23= 1 })->place(-relx => 0.45, -rely => 0.2);
$cb_value_24 = 0;
$cb_value= $mw -> Checkbutton(-variable => \$cb_value_24, -command => sub { $cb_value_24= 1 })->place(-relx => 0.45, -rely => 0.3);
$cb_value_25 = 0;
$cb_value= $mw -> Checkbutton(-variable => \$cb_value_25, -command => sub { $cb_value_25= 1 })->place(-relx => 0.45, -rely => 0.4);
$cb_value_26 = 0;
$cb_value= $mw -> Checkbutton(-variable => \$cb_value_26, -command => sub { $cb_value_26= 1 })->place(-relx => 0.55, -rely => 0.1);
$cb_value_27 = 0;
$cb_value= $mw -> Checkbutton(-variable => \$cb_value_27, -command => sub { $cb_value_27 = 1 })->place(-relx => 0.55, -rely => 0.2);
$cb_value_28 = 0;
$cb_value= $mw -> Checkbutton(-variable => \$cb_value_28, -command => sub { $cb_value_28= 1 })->place(-relx => 0.55, -rely => 0.3);
$cb_value_29 = 0;
$cb_value= $mw -> Checkbutton(-variable => \$cb_value_29, -command => sub { $cb_value_29= 1 })->place(-relx => 0.55, -rely => 0.4);
$cb_value_30 = 0;
$cb_value= $mw -> Checkbutton(-variable => \$cb_value_30, -command => sub { $cb_value_30= 1 })->place(-relx => 0.55, -rely => 0.5);
$cb_value_31 = 0;
$cb_value= $mw -> Checkbutton(-variable => \$cb_value_31, -command => sub { $cb_value_31= 1 })->place(-relx => 0.55, -rely => 0.6);
$cb_value_32 = 0;
$cb_value= $mw -> Checkbutton(-variable => \$cb_value_32, -command => sub { $cb_value_32= 1 })->place(-relx => 0.55, -rely => 0.7);
$cb_value_33 = 0;
$cb_value= $mw -> Checkbutton(-variable => \$cb_value_33, -command => sub { $cb_value_33 = 1 })->place(-relx => 0.55, -rely => 0.8);
$cb_value_34 = 0;
$cb_value= $mw -> Checkbutton(-variable => \$cb_value_34, -command => sub { $cb_value_34 = 1 })->place(-relx => 0.55, -rely => 0.9);
$cb_value_35 = 0;
$cb_value= $mw -> Checkbutton(-variable => \$cb_value_35, -command => sub { $cb_value_35 = 1 })->place(-relx => 0.65, -rely => 0.1);
$cb_value_36 = 0;
$cb_value= $mw -> Checkbutton(-variable => \$cb_value_36, -command => sub { $cb_value_36= 1 })->place(-relx => 0.65, -rely => 0.2);
$cb_value_37 = 0;
$cb_value= $mw -> Checkbutton(-variable => \$cb_value_37, -command => sub { $cb_value_37= 1 })->place(-relx => 0.65, -rely => 0.3);
$cb_value_38 = 0;
$cb_value= $mw -> Checkbutton(-variable => \$cb_value_38, -command => sub { $cb_value_38= 1 })->place(-relx => 0.65, -rely => 0.4);
$cb_value_39 = 0;
$cb_value= $mw -> Checkbutton(-variable => \$cb_value_39, -command => sub { $cb_value_39 = 1 })->place(-relx => 0.75, -rely => 0.1);
$cb_value_40 = 0;
$cb_value= $mw -> Checkbutton(-variable => \$cb_value_40, -command => sub { $cb_value_40= 1 })->place(-relx => 0.75, -rely => 0.2);
$cb_value_41 = 0;
$cb_value= $mw -> Checkbutton(-variable => \$cb_value_41, -command => sub { $cb_value_41= 1 })->place(-relx => 0.75, -rely => 0.3);
$cb_value_42 = 0;
$cb_value= $mw -> Checkbutton(-variable => \$cb_value_42, -command => sub { $cb_value_42= 1 })->place(-relx => 0.75, -rely => 0.4);
$cb_value_43 = 0;
$cb_value= $mw -> Checkbutton(-variable => \$cb_value_43, -command => sub { $cb_value_43 = 1 })->place(-relx => 0.75, -rely => 0.5);
$cb_value_44 = 0;
$cb_value= $mw -> Checkbutton(-variable => \$cb_value_44, -command => sub { $cb_value_44= 1 })->place(-relx => 0.75, -rely => 0.6);
$cb_value_45 = 0;
$cb_value= $mw -> Checkbutton(-variable => \$cb_value_45, -command => sub { $cb_value_45= 1 })->place(-relx => 0.75, -rely => 0.7);
$cb_value_46 = 0;
$cb_value= $mw -> Checkbutton(-variable => \$cb_value_46, -command => sub { $cb_value_46 = 1 })->place(-relx => 0.75, -rely => 0.8);
$cb_value_47 = 0;
$cb_value= $mw -> Checkbutton(-variable => \$cb_value_47, -command => sub { $cb_value_47= 1 })->place(-relx => 0.75, -rely => 0.9);
$cb_value_48 = 0;
$cb_value= $mw -> Checkbutton(-variable => \$cb_value_48, -command => sub { $cb_value_48 = 1 })->place(-relx => 0.85, -rely => 0.1);
$cb_value_49 = 0;
$cb_value= $mw -> Checkbutton(-variable => \$cb_value_49, -command => sub { $cb_value_49 = 1 })->place(-relx => 0.85, -rely => 0.2);
$cb_value_50= 0;
$cb_value= $mw -> Checkbutton(-variable => \$cb_value_50, -command => sub { $cb_value_50= 1 })->place(-relx => 0.85, -rely => 0.3);
$cb_value_51 = 0;
$cb_value= $mw -> Checkbutton(-variable => \$cb_value_51, -command => sub { $cb_value_51 = 1 })->place(-relx => 0.85, -rely => 0.4);

$mw->Button(-text => "RESET", -command =>  sub { exec("C:\"\\Documents and Settings\"\\Administrator\\Desktop\\poker.pl\"");})->place(-relx => 0.85, -rely => 0.75);
MainLoop;

Danke für jede Hilfe schon im vorhinein

Mfg
Byron
 
Du kannst ganz normale Netzwerkprogrammierung mit Perl machen, z.B. in dem Du Sockets verwendest. Perl kennt die ganzen System-Calls, mit denen man das klassischerweise unter C gemacht haette.

Problematisch ist nur, dass man die MainLoop staendig unterbrechen muss, um nach eingegangen Informationen zu schauen. Vielleicht gibt es dafuer ein Modul? Bei Perl-Problemen gilt ja sowieso: guckst Du CPAN ... Die allermeisten Probleme sind schon geloest.
 

abgdf

Guru
Hi,

Weiter wäre es angenehm, wenn ich mir die angeklickten Checkboxen zählen lassen könnte und mir auf der Oberfläche ausgegeben wird?!

Äh, ich wundere mich gerade, warum die Variablen $cb_value_49 usw. so ohne "my" akzeptiert werden. Ach so, kein "use strict;". Wäre aber besser.
Du kannst dann - wenn es sein muß - trotzdem globale Variablen erzeugen mit

Code:
use vars qw($cb_value_0 $cb_value_50)

....

$cb_value_50 = 0;

usw.

Das mit den Checkbuttons könntest Du z.B. so machen:
Definier einen Button mit Label "count", ordne ihm eine Funktion (= sub) zu und prüfe darin die Werte der Variablen $cb_value_0

(nebenbei: Vielleicht solltest Du lieber eine Liste verwenden

Code:
my @cb_values=();
$cb_values[0]=0;
die kann man leichter durchgehen ...)

usw.. Zähle in einer Variablen, wieviele davon 1 sind und zeige das Ergebnis z.B. in einem "Label" an.

Viele Grüße
 
Oben