3 Einträge, 1 Seite |
1
2
print&f(($_=(3x3)."3+33")=~s=3(?![^3]|$)=&f=eg);
sub f{eval(@_?$_:"'$&+'x3");}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/perl
use strict;
use warnings;
use Curses;
use Curses::Widgets;
use Curses::Widgets::Label;
use Curses::Widgets::ListBox;
my $win = Curses->new;
noecho();
$win->keypad(1);
curs_set(0);
my $l = Curses::Widgets::Label->new({
CAPTION => 'INFO:',
BORDERCOL => 'white',
BORDER => 1,
COLUMNS => 50,
LINES => 5,
VALUE => <<EOT,
SPACE => Select item
CTRL + D => Delete selected item
ENTER => Exit example
EOT
FOREGROUND => 'white',
BACKGROUND => 'grey',
X => 1,
Y => 1,
ALIGNMENT => 'L',
});
$l->draw($win);
my $lb = Curses::Widgets::ListBox->new({
CAPTION => 'List',
LENGTH => 10,
LINES => 10,
BORDERCOL => 'blue',
SELECTEDCOL => 'green',
FOREGROUND => 'white',
VALUE => 0,
FOCUSSWITCH => "\n",
X => 25,
Y => 10,
LISTITEMS => ['aaa'..'aaz' ],
CURSORPOS => 0,
INPUTFUNC => \&lb_scankey,
});
$lb->draw($win, 1);
$lb->execute($win);
$win->erase();
endwin();
sub lb_scankey {
my $mwh = shift;
my $key = -1;
while( $key eq -1 ) {
$key = $mwh->getch;
if( ord($key) == 0x04 ) { # ^D pressed
my $items = $lb->getField('LISTITEMS');
my $curpos = $lb->getField('CURSORPOS');
splice(@$items, $curpos, 1)
if scalar(@$items);
}
}
return $key;
}
3 Einträge, 1 Seite |