O'Reilly logo

Effective Perl Programming: Ways to Write Better, More Idiomatic Perl, Second Edition by brian d foy, Joshua A. McAdams, Joseph N. Hall

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

4. Subroutines

A big part of Perl’s power as a dynamic language comes from its malleable subroutines. You don’t have to do much to define a subroutine. You don’t have to tell it how many parameters it will receive, or what types of data you will give it. You can pass a subroutine any list that you like and figure out what to do with it later. Although Perl is very permissive and gives you plenty of flexibility to decide things as late as possible. Despite that, there is a lot that you can do to keep yourself from being too flexible.

You don’t even have to define subroutines ahead of time, either. You can make new ones at run time and you can even redefine them later. You can write subroutines that create other subroutines. Each of those subroutines ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required