examples/char.pl
raw| 1 | use strict; |
| 2 | use warnings; |
| 3 | use FFI::Platypus 2.00; |
| 4 | |
| 5 | my $ffi = FFI::Platypus->new( api => 2 ); |
| 6 | $ffi->lib(undef); |
| 7 | $ffi->type('int' => 'character'); |
| 8 | |
| 9 | my @list = qw( |
| 10 | alnum alpha ascii blank cntrl digit lower print punct |
| 11 | space upper xdigit |
| 12 | ); |
| 13 | |
| 14 | $ffi->attach("is$_" => ['character'] => 'int') for @list; |
| 15 | |
| 16 | my $char = shift(@ARGV) || 'a'; |
| 17 | |
| 18 | no strict 'refs'; |
| 19 | printf "'%s' is %s %s\n", $char, $_, &{'is'.$_}(ord $char) for @list; |