Monday 15 August 2011

how to execute the perl script when the script names are written in txt file -



how to execute the perl script when the script names are written in txt file -

question : have normal txt file has perl script names , flag set it,please see illustration below, want read txt file , if flag set 1 execute perl scripts . how ?

test.txt tc1connect.pl = 1 tc2disconnect.pl = 1 tc3action = 0

thanks in advance.

try below code . execute perl scripts set flag 1

input file:(test.txt)

tc1connect.pl = 1 tc2disconnect.pl = 1 tc3action = 0

code:

use strict; utilize warnings; open $fh, '<', "test.txt" or die "couldn't open text file"; while (<$fh>) { chomp; if ( $_ =~ /(.*?\.pl)\s*=\s*(0|1)/ ) { $perl_program = $1; if ( $2 == 1 ) { scheme "perl $perl_program" , die "error running $perl_program: $!"; } } } close($fh);

perl perl-module perl-data-structures

No comments:

Post a Comment