Saurabh Singhvi wrote:
HI all,

Hello,

i want to write a perl script in linux that would get the file names
in the directory i am running it in and then execute a system command
for each file.(the encoding line). how should i go about it??

Something like this should work:

#!/usr/bin/perl
use warnings;
use strict;

my $command = 'file';

opendir my $D, '.' or die "Cannot open the current directory: $!";

while ( my $file = readdir $D ) {

    next if $file =~ /^\.\.?$/;  # skip entries '.' and '..'

    system( $command, $file ) == 0 or die "system $command $file failed: $?";
    }

closedir $D;

__END__



John
--
use Perl;
program
fulfillment

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to