Quoting pieces of code would fall under fair use for this case. Also here's the license for the code in question:
https://hop.perl.plover.com/Examples/. And here's a github repo somebody else created for the code examples in the book:
https://github.com/tomhickerson/hoperl.