[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] opening files in afolder



Dear MacPerl Experts'

i'm trying to read the contents of files in a folder and add it to a single
file.

i'm able to read the file names in the folder

but i can not  read  the contents of the files.

it appears  that i am at the wrong dir level.

if i move a file out of its folder i can read it!

here is my code:

#!perl

print ("What is the name of your folder?   ");

$myFOLDER = <STDIN> ;
chomp($myFOLDER);

print ("you picked folder $myFOLDER \n");

open(mydata, "+>fas_seq") or die ('Could not make file');

opendir(DIR, "$myFOLDER") or die " could not open $myFOLDER";
@files = readdir(DIR);
closedir(DIR);

foreach $file (@files) {
       print("$file\n");
       print mydata (">$file\n");

	open(IN, "$file") or die ("could not open file $file");

	while( $_ = <IN> ){

		print "$_";
		print mydata "$_";
	}

	close(IN);

  }

close(mydata);

here is the error:

# could not open file 09 R2S3-REV, <STDIN> chunk 1.

any advise?

thank you very much.





# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org