From owner-freebsd-questions@FreeBSD.ORG Thu May 20 01:39:10 2010 Return-Path: Delivered-To: questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E1D90106566B for ; Thu, 20 May 2010 01:39:10 +0000 (UTC) (envelope-from steve@ipv6canada.com) Received: from smtp.ibctech.ca (v6.ibctech.ca [IPv6:2607:f118::b6]) by mx1.freebsd.org (Postfix) with SMTP id 6B4168FC0A for ; Thu, 20 May 2010 01:39:10 +0000 (UTC) Received: (qmail 16190 invoked by uid 89); 20 May 2010 01:41:38 -0000 Received: from unknown (HELO ?IPv6:2607:f118::5?) (steve@ibctech.ca@2607:f118::5) by 2607:f118::b6 with ESMTPA; 20 May 2010 01:41:38 -0000 Message-ID: <4BF492BB.2010100@ipv6canada.com> Date: Wed, 19 May 2010 21:39:07 -0400 From: Steve Bertrand User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.7) Gecko/20100111 Lightning/1.0b1 Thunderbird/3.0.1 MIME-Version: 1.0 To: "questions@freebsd.org" X-Enigmail-Version: 1.0.1 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: Subject: Searching for functions in Perl code X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 May 2010 01:39:11 -0000 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