i need a help to do program.i need to read multiple files and need to print out result in to new file.I had stored my datas in mycomputer/programs(G:)/CNV/(inside this i have 4 folder and each folder consits of number of datas...) plz give me perl script to do this

7 Years
Discussion Span
Last Post by anunitha

The File::Find module process the multiple sub directories.

use strict;
use warnings;
use File::Find;

my $root_path=qq{G:/CNV}; #Declare your input path

# Recursively it process all the sub directories in $root_path
find(\&process_multiple_dir, $root_path); 

sub process_multiple_dir
  if (-f && $File::Find::name =~ m{\.txt$}) # It process .txt format files only
    undef $/;  # Input Record separator

    # Files Handling process 
    open (FIN, "<$File::Find::name") || die "Cannot Open the Input file";
    my $file=<FIN>;  # Assign the file handler to scalar variable
    close (FIN);

    # Change the file name for the output file creation purpose
    $File::Find::name=~ s{\.txt}{_Out.txt};

    # Do your file process here
    # . . . 
    # . . . 
    # . . . 

    # Print the $file contents to new file
    open (FOUT, ">$File::Find::name") || die "Cannot Create the Output file";
    print FOUT $file;
    close (FOUT);

Edited by k_manimuthu: Most of the lines wrap. For better view purpose I edit the thread


Hi Thanks for your script.am new to programing side,just now am learning,i wll work out and see.

Edited by anunitha: n/a


sir,i did but am not getting,k now i wish to get some script to compare 2 micrarrya data's
1.my computer->program(G:)-> DTATA(folder)->inside this i have 5 folder more each folder consists of 1000 of data
a.microD(folder 1->consits of many data)
b.microA("2 ")
c.microE(3 )
d.microF(4 ")
e.microG(5 ")
like this i have different folder inside main folder DATA
in this i wish to take 2datas d,e folder inside this i have each 10 datas i need to compare these 2 datas i need to find same starting posistion and ending position in these 2 data ,how i need take in put and print the result in new folder..
in the 2 data also i have same i need to compare this start-pos,and end-postion,
how to take input...

Edited by anunitha: n/a

This article has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.