Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: detecting pod in files?

by Ven'Tatsu (Deacon)
on Aug 17, 2005 at 14:30 UTC ( [id://484443]=note: print w/replies, xml ) Need Help??


in reply to detecting pod in files?

I wouldn't call it easyer but at the first detection of a pod directive I would set the flag an bail out of the loop instead of searching the rest of the file. It is also posible that a file will not contain '=pod' but still have pod in it. I would use something like this:
my $file = '/tmp/file'; open(IN, "<$file") or die "$0: cannot read file '$file': $!"; my $pod = 0; while (<IN>) { $pod = 1, last if /^=\w/ } #/^=(pod|head\d|over|item|back|cut)/ might be more accurate #=begin, =end, and =for are ommited because they would #usualy be ignored by pod2* close(IN); pod2html($file) if $pod;

Replies are listed 'Best First'.
Re^2: detecting pod in files?
by brian_d_foy (Abbot) on Aug 17, 2005 at 17:17 UTC

    You can't do it this simply. Although a pod directive starts at the beginning of a line with an =, that has to happen when Perl isn't expecting something else. (Curiously, BBEdit gets this wrong too).

    # this isn't pod $time =time ;
    Or
    $string =<<"HERE"; =value =item HERE

    You can can't just look for a particular pod directive (such as =pod, in the original post, because it might not show up. Indeed, I have rarely used =pod.

    There are plenty of Pod modules, so use those instead of rolling your own. :)

    --
    brian d foy <brian@stonehenge.com>

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2024-04-19 04:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found