4 ms·
Perl 6 is my go-to language for writing command line utilities. The combination of MAIN subroutines, named regexes and full-blown grammars makes it simple to wr
by donaldihunter 10y ago
Perl 6 is my go-to language for writing command line utilities. The combination of MAIN subroutines, named regexes and full-blown grammars makes it simple to write documented, maintainable programs that can parse just about anything. Oh and Unicode support is awesome. This protobuf grammar is a good example of what Perl 6 grammars are like - https://github.com/donaldh/p6-pb/blob/master/lib/PB/Grammar.pm https://github.com/donaldh/p6-pb/blob/master/lib/PB/Grammar.... - and worth comparing to the official protobuf language specification - https://developers.google.com/protocol-buffers/docs/reference/proto3-spec https://developers.google.com/protocol-buffers/docs/referenc...
- donaldihunter 10y agoHere's an example of a MAIN subroutine with POD6 documentation that produces a good command line usage message https://github.com/donaldh/swagger-to-yang/blob/master/swagger-to-yang.pl https://github.com/donaldh/swagger-to-yang/blob/master/swagg... https://github.com/donaldh/swagger-to-yang#usage https://github.com/donaldh/swagger-to-yang#usage
- donaldihunter 10y agoLow-level stuff on a Raspberry Pi, including native C library calls for mmap, munmap. Binding the mmap library call into Perl 6 is as simple as: sub mmap(Pointer $addr, int32 $length, int32 $prot, int32 $flags, int32 $fd, int32 $offset) returns CArray[int32] is native {*} https://github.com/donaldh/Perl6-RPi-GpioDirect/blob/master/lib/RPi/GpioDirect.pm https://github.com/donaldh/Perl6-RPi-GpioDirect/blob/master/...