Re: grep file file handle
- From: "MSG" <OliverPC@xxxxxxxxx>
- Date: 30 Mar 2006 20:56:17 -0800
perlnewbie02 wrote:
use strict;
use warnings;
Should always check against failure
opendir DIR, '.';
while ($filename = readdir DIR)You are using readdir in a scalar context,
but grep operates on an array/list. so if you want to utilize grep(),
this probably will get from the current directory all .html files that
is less than a day old:
my @html_files = grep { /\.html$/i && -M $_ < 1 } readdir DIR ;
Here readdir is used in a list context.
.
- References:
- grep file file handle
- From: perlnewbie02
- grep file file handle
- Prev by Date: Re: Counting specific elements in a XML object
- Next by Date: Re: the only difference is the 'x' after '/g'
- Previous by thread: grep file file handle
- Index(es):
Relevant Pages
|