#!/usr/bin/perl print "Content-type:text/html\n\n"; $parval="stat1_val"; if($parval eq "stat1_val"){ print "Statistics of RUNS"; my $var ; my $buffer=$ENV{'QUERY_STRING'}; my($path1,$filename)=split('#',$buffer); print "$path1 and $filename\n"; print "
"; for my $path ( grep -d, ) { my($first,$second,$third,$directory,$batches)=split('/',$path); my($ss,$ss1)=split('batch',$path); print "
  • $ss1 $batches
  • "; } my @var=`ls -f $path1| grep '.txt\$'`; foreach $var(@var){ $var=~s/\s+//g; print qq{
  • $i $var
  • }; } print "
    "; } my program output is like this 1 batch1 2 batch2 3 batch3 4 batch4 5 batch5 file2.txt file5.txt file1.txt file3.txt but i need it in the following format 1 batch1 file2.txt file5.txt file1.txt file3.txt 2 batch2 3 batch3 4 batch4 5 batch5