Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Parse POD of a method from perl module

by kcott (Archbishop)
on May 14, 2014 at 04:48 UTC ( [id://1085976]=note: print w/replies, xml ) Need Help??


in reply to Parse POD of a method from perl module

G'day perlUser9,

Welcome to the monastery.

This seems to do what you want. Using your example code, this outputs just "My POD for Subroutine2\n". I added some extra dummy POD for test purposes.

#!/usr/bin/env perl use strict; use warnings; my $wanted_sub = 'Subroutine2'; my $pod_string; { local $/ = "\n=head1 "; while (<DATA>) { if (/\A $wanted_sub $/mx) { ($pod_string = $_) =~ s/\A .+? ^ ( .+? ) =cut .* \z/$1/msx +; last; } } } print $pod_string; __DATA__ package MyModule; =head1 Subroutine1 My POD for Subroutine1 =cut sub Subroutine1 { ... ... } =head1 Subroutine2 My POD for Subroutine2 =head2 Dummy Heading 2 =over 4 =item whatever qwerty =item blah asdfgh =back Some text =cut sub Subroutine2 { ... ... } 1;

Output:

My POD for Subroutine2 =head2 Dummy Heading 2 =over 4 =item whatever qwerty =item blah asdfgh =back Some text

-- Ken

Replies are listed 'Best First'.
Re^2: Parse POD of a method from perl module
by Anonymous Monk on May 15, 2014 at 05:13 UTC
    Hi All, Thanks a lot for your help. I wrote my code to extract the POD for a particular method and used Pod::Text module to covert the pod to plain text. Thanks again for the guidance.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1085976]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (7)
As of 2024-03-29 15:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found