Vamsi_Doddapaneni wrote on Montag, 9. Mai 2005 12:16

> Here is the code part:
>  foreach $name(`ls $opt_i/*.xml`){
>     chomp;
>     push @f, $name;
>       print "pushing elements=$name\n";
> }
> [EMAIL PROTECTED];

> Now in the directory $opt_i if there are some 10 , 20 or even 100 its
> working  well. But now I have some 305 odd xmls and the code is
EXITING
> WITH


> sh: /usr/bin/ls: 0403-027 The parameter list is too long.


It's strange that your ls fails to handle 300+ files - is $opt_i being
expanded correctly? And I don't ever recall seeing an ls display an
error code upon failure.

In any case, I would suggest using the Perl built-in to read the
directory listing, instead of using the system ls command.

Here's sample, albeit untested code:

my $sample_dir = $opt_i;
chdir $sample_dir || die "\nFatal error : Cannot cd to $sample_dir\n";
opendir SAMPLEDIR, $sample_dir || die "\nFatal error : Cannot read
directory $sample_dir.\n";
my @ELEMENTS = grep /\.xml$/, readdir SAMPLEDIR;
close SAMPLEDIR;


The list @ELEMENTS will contain all *.xml files in $opt_i, if any.


BTW, this is slightly OT for the DBI-users list.


Cheers,
Srikanth Madani

Life is short. Be swift to love! Make haste to be kind!
-Henri Frederic Amiel

Reply via email to