sub textsformat { # variables: initialization ... ... ... my $text =$_[0]; open (MYFILE, "<$text") || die "the file $text is not readable: $!" ; open (OUTPUT, ">$text.txt") || die "can not open $text\.txt with the permission write: $!"; LINE: while() { ..... # Algo for formatting a textfile }; close(MYFILE); close(OUTPUT); }; sub dir_explorer { my $entry = $_ ; if (-d $entry) { ... # ignore . and .. opendir(DIR, $entry) or die "Can not open $entry: $!"; open(FILE, ">>$entry.tab") or die "Can not open $entry with the permission write: $!"; while( defined (my $file = readdir DIR) ) { if (-f "$entry/$file") { textsformat("$entry/$file"); # .... }; }; close(FILE); closedir(DIR); }; }; find(\&dir_explorer, "/home/dub/S/programming/perl/dp");