#!/usr/bin/perl -w use strict; my @TestInput = ( 'Line One', 'Line Two', 'Line Three', 'Line Four', 'Line Five', ); foreach my $testLine (@TestInput) { print "-----> '$testLine'\n"; if(/(\d\_)+a1/.../(\d\_)+a1/) { my $var3 = "$outdir/$1 +to+ $2.txt"; print " Found '$var3'\n"; } } exit; #### #!/usr/bin/perl -w use strict; { print"enter the input directory path:\n"; chomp($indir=); print"enter the output directory name:\n"; chomp($outdir=); if ($indir eq $outdir) { print"you cannot have same input and ouput directory please change:\n"; exit(); } else { chdir ("$indir") or die "$!"; opendir(DIR,".") or die "$!"; my @files=readdir DIR; print @files; close DIR; foreach $file(@files) { unless (($file eq ".") || ($file eq "..") ) { $filer="$indir/$file"; open filein,$filer; while () { if(/(\d\_)+a1/.../(\d\_)+a1/) { print; $var3="$outdir/$1 +to+ $2.txt"; open filew,">>$var3" or die "cannot open $out:$!"; print filew $_,"\n"; } } } } print"<----------------------------------------------->\n"; print "\t\t action done\n"; print "\a"; print "\a"; print "\a"; print"<----------------------------------------------->\n"; print"Results could be found in $outdir as txt files with TC name\n"; print"<**********************..............*************************>>\n"; close $out; } } exit;