Thread Sockets / Hash - Switch Statement (4 answers)
Opened by Gast at 2005-01-10 00:45

esskar
 2005-01-10 00:51
#50657 #50657
User since
2003-08-04
7321 Artikel
ModeratorIn

user image
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
while ( <$client> ) {
  next unless /\S/;       # blank line

  chomp;

  my %commands = (
    'quit'  => sub { $exit = 1; last; },
    'title' => \&title,
    'next'  => \&next_title,
    'prev'  => \&prev_title,
  );

  if ( defined( $commands{$_} ) ) {
    $commands{$_}->();
  } else {
    print $client "Commands: quit title prev next", $CRLF;
  }
}
\n\n

<!--EDIT|esskar|1105311104-->

View full thread Sockets / Hash - Switch Statement