Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 19 May 2010 21:39:07 -0400
From:      Steve Bertrand <steve@ipv6canada.com>
To:        "questions@freebsd.org" <questions@freebsd.org>
Subject:   Searching for functions in Perl code
Message-ID:  <4BF492BB.2010100@ipv6canada.com>

next in thread | raw e-mail | index | archive | help
This is more of a handy how-to than it is a question. A permanent
'howto' as it were.

A Perl project I'm working on contains 457 functions (ie. subroutines
(ie methods)), and even though I have documentation for all of them,
sometimes it is handy to have a list in front of me.

This is how I produce the list of all sub-routines within all module
files, which includes the module name and sub.

% grep -E -r "sub \w+ {" * | grep -v svn | awk '{FS=":"} \
{print $1, " ", $2}' | awk '{FS=" "} {print $1, " ", $3}'

...adapted to pull subs from a single file:

% cat lib/ISP/User.pm | grep -E "sub \w+ {" | awk '{print $2}'

For efficiency, and so I can remember more readily, my request is for
golf, particularly adaption to a Perl one-liner ;)

Cheers,

Steve




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4BF492BB.2010100>