| grok documentation | Contained in the grok distribution. |
App::Grok::Resource::File - Standard file resource for grok
use strict;
use warnings;
use App::Grok::Resource::File qw<:ALL>;
# this will return everything in $PERL6LIB sometime in the future
my @index = file_index();
# get a filehandle to the thing we want
my $handle = file_fetch('perlintro');
This resource finds arbitrary documentation on the filesystem.
file_indexThis method doesn't return anything useful yet.
file_fetchTakes a module name, program name, or Pod page name. Since the details of
$PERL6LIB are still fuzzy, it currently just returns the contents of
the supplied file.
file_locateReturns the filename given if it is a real file. Not very useful.
| grok documentation | Contained in the grok distribution. |
package App::Grok::Resource::File; BEGIN { $App::Grok::Resource::File::AUTHORITY = 'cpan:HINRIK'; } BEGIN { $App::Grok::Resource::File::VERSION = '0.25'; } use strict; use warnings FATAL => 'all'; use base qw(Exporter); our @EXPORT_OK = qw(file_index file_fetch file_locate); our %EXPORT_TAGS = ( ALL => [@EXPORT_OK] ); sub file_fetch { my ($file) = @_; # TODO: at some point we'll search through $PERL6LIB, but for now # we only accept a concrete path if (-f $file) { open my $handle, '<', $file or die "Can't open $file: $!"; my $pod = do { local $/ = undef; scalar <$handle> }; close $handle; return $pod; } return; } sub file_index { # this might recurse through $PERL6LIB or something at some point return; } sub file_locate { my ($file) = @_; return $file if -f $file; return; } 1;