Shameem Ahamed wrote:
> Hi All,
> 
> I am wondering how can i use the glob  function to get only the first few 
> files.
> 
> 
> I have files with digits as extensions. Like file.0, file.1 
> file.2......file.100,file.101 etc.
> 
> I want to select only the first 30 files.
> 
> I used glob("file.[0-4]?[0-9]") but it doesn't seem to be working. The glob 
> function trying to parse ? as separate, and matches all three digit 
> extensions.
> 
> How can i sort this out ?.
> 
> Shammi

It's because glob() uses the shell expansion, not regex.  In the shell,
? means any character.  You could use a regex filter:

my @files = grep { /^file\.[0-4]?[0-9]$/ } glob( 'file.[0-9]*' );


-- 
Just my 0.00000002 million dollars worth,
  Shawn

Programming is as much about organization and communication
as it is about coding.

I like Perl; it's the only language where you can bless your
thingy.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to