On the same lines I have question to all Perl Gurus. In this scenario can we
following? And if Yes, how efficient it is?

#!/usr/bin/perl
#Author: Parag Kalra

use strict;
use warnings;

# Creating 50 files - you can skip this
foreach(1..50){
    open my $fh, '>', 'file.'.$_;
}
my @Req_Input_Files;

# Getting first 30 files out of the lot of 50
foreach(1..30){
    my $tmp_file = 'file.'.$_;
    push @Req_Input_Files, glob $tmp_file;
}

print  "@Req_Input_Files\n";

O/P:

perl Search_30_Files.pl

file.1 file.2 file.3 file.4 file.5 file.6 file.7 file.8 file.9 file.10
file.11 file.12 file.13 file.14 file.15 file.16 file.17 file.18 file.19
file.20
 file.21 file.22 file.23 file.24 file.25 file.26 file.27 file.28 file.29
file.30


Cheers,
Parag




On Wed, Jan 20, 2010 at 2:20 PM, Shameem Ahamed <shameem.aha...@yahoo.com>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
>
>
>
>
>
> --
> 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