Member Avatar for anunitha

Hi,
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

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);
  }
}
Member Avatar for anunitha

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

Member Avatar for anunitha

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..
(sample-id|chromosome|start-pos|end-pos[/U]|num-snp|cnv-length|hmm-state|copy-number|start-snp|end-snp)
in the 2 data also i have same i need to compare this start-pos,and end-postion,
how to take input...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.