/[Frey]/branches/zimbardo/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

Annotation of /branches/zimbardo/lib/Frey/File.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 818 - (hide annotations)
Fri Dec 12 18:00:21 2008 UTC (15 years, 5 months ago) by dpavlin
Original Path: trunk/lib/Frey/File.pm
File size: 585 byte(s)
added dir_extension helper for opendir
1 dpavlin 719 package Frey::File;
2     use Moose::Role;
3    
4     use File::Slurp qw//;
5    
6 dpavlin 818 =head2 read_file
7    
8     L<File::Slurp/read_file>
9    
10     =cut
11    
12 dpavlin 721 sub read_file { shift ; File::Slurp::read_file( @_ ) }
13 dpavlin 818
14     =head2 write_file
15    
16     L<File::Slurp/write_file>
17    
18     =cut
19    
20 dpavlin 721 sub write_file { shift ; File::Slurp::write_file( @_ ) }
21 dpavlin 719
22 dpavlin 818 =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 dpavlin 719 1;

  ViewVC Help
Powered by ViewVC 1.1.26