Skip to Content
Higher-Order Perl
book

Higher-Order Perl

by Mark Jason Dominus
March 2005
Intermediate to advanced
600 pages
14h
English
Morgan Kaufmann
Content preview from Higher-Order Perl

CHAPTER 1 RECURSION AND CALLBACKS

The first “advanced” technique we’ll see is recursion. Recursion is a method of solving a problem by reducing it to a simpler problem of the same type.

Unlike most of the techniques in this book, recursion is already well known and widely understood. But it will underlie several of the later techniques, and so we need to have a good understanding of its fine points.

1.1 DECIMAL TO BINARY CONVERSION

Until the release of Perl 5.6.0, there was no good way to generate a binary numeral in Perl. Starting in 5.6.0, you can use sprintf (“%b”, $num), but before that the question of how to do this was Frequently Asked.

Any whole number has the form 2k + b, where k is some smaller whole number and b is either 0 or 1. ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Beginning Perl

Beginning Perl

Curtis Ovid Poe
Think Perl 6

Think Perl 6

Laurent Rosenfeld, Allen B. Downey
Minimal Perl

Minimal Perl

Tim Maher
Perl by Example

Perl by Example

Ellie Quigley

Publisher Resources

ISBN: 9781558607019