is it possible to open and work in two files from same or different location simultaneously.

How it is possible? Please suggest

Thanks / Regards
Mahesh

is it possible to open and work in two files from same or different location simultaneously.

How it is possible? Please suggest

Thanks / Regards
Mahesh

Yes it is possible. How? When you open a file you assign it to a file handle which you give any name you want. You can open another file and assign it to a file handle with a different name. You can read more about opening files here

open(IN,"<","input.txt");
open(OUT,">","output.txt");
while(<IN>){
  chomp;
  #do something with IN
  print OUT "something to OUT\n";
}

My laptop freaked out and I posted twice. Sorry.

open(IN,"<","input.txt");
open(OUT,">","output.txt");
while(<IN>){
  chomp;
  #do something with IN
  print OUT "something to OUT\n";
}
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.