/[Frey]/trunk/lib/Frey/File.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /trunk/lib/Frey/File.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 818 - (show annotations)
Fri Dec 12 18:00:21 2008 UTC (15 years, 4 months ago) by dpavlin
File size: 585 byte(s)
added dir_extension helper for opendir
1 package Frey::File;
2 use Moose::Role;
3
4 use File::Slurp qw//;
5
6 =head2 read_file
7
8 L<File::Slurp/read_file>
9
10 =cut
11
12 sub read_file { shift ; File::Slurp::read_file( @_ ) }
13
14 =head2 write_file
15
16 L<File::Slurp/write_file>
17
18 =cut
19
20 sub write_file { shift ; File::Slurp::write_file( @_ ) }
21
22 =head2 dir_extension
23
24 my @files = $self->dir_extension( 'var/directory/', '\.(ya?ml)$' );
25
26 =cut
27
28 sub dir_extension {
29 my ($self,$path,$extension) = @_;
30
31 opendir(my $dir, $path) || die "can't opendir $path: $!";
32 my @files = sort grep { m/$extension/ } readdir($dir);
33 closedir $dir;
34 return @files;
35 }
36
37 1;

  ViewVC Help
Powered by ViewVC 1.1.26