Jakob Kofoed wrote: > Hi again,
Hi, > Sorry for the delayed answer. Tha's okay, but please don't top-post. Instead trim out anything to which you are noit directly replying, and follow comments with your specific responses, then add anything new in a block following. It helps to keep the flow of discussion cogent. > > > Thank you for all your comments (Yes Joseph, I will try to enhance my basic > abilities - sorry for the bad code:-) Actually, the issue is not so much code as meaning. As you translate a real-world problem into code, try not to let the meaning become less clear. Imagination helps considerably. If you have any way to visualize the matter your code is describing, try to do that. Then it should be much more clear what variable names would best describe the real-world matter. > > > My thoughts on this project was to make a perl script which copy the content > of a tape to disk, no matter if it is tar archives, binary files, EBCDIC and > so on, much like the UNIX tcopy. Don't try to do it all with the same code. Instead of writing a script, write a program, with separate fucntions designed for each kind of file you may to encounter. You will save yourself a world of grief approaching the problem this way. > But, I work on Linux and don't have the > tcopy available. Oboy, I don't know about this. This seems like a prety demanding project. If this is production work, I would recommend that you Google for some product that has already ben proven, but... What is the format in which the tape files are stored? This is going to be critical. Since tape is a sequential medium, I assume that each file should be preceded by some form of header, rather than using a central directory as with a dsik I don't know, though. It is critical that, if you take on this project, you find out and use this information. Your best bet is to use file and block size information as you process. That is until(end_of_tape_reached()) { my $file_info = get_file_information(\*TAPE_STREAM); extract_file($file_info, \*TAPE_STREAM); } sub extract_file { my ($file_info, $tape_stream) = @_; my $file_type = $file_info->{'file type'}; my $storage_schema = $file_info->{storage schema'}; if ($file_type eq 'EBCIDIC') { extract_as_EBCIDIC($file_info, $storage_schema, $tape_stream); } elsif ($file_type eq 'binary') { extract_as_binary(($file_info, $storage_schema, $tape_stream); ... } } ... > > > When you write multiple files to a tape it creates an physical "end of file > marker" at the end of each file. When some applications write to tape they > make an EOF between each file and then a double EOF at the end of the tape. I think you may be causing trouble for yourself trying to do character-based transfer. The difference in encodings should raise an alarm bell on that score. Why not look for the file size for each file to be transferred, and then use binary-mode IO? As I said, I really know nothing about the way files are stored on tape. The last tape drive I used was audio tape to load programs onto my Timex-Sinclair 1000. Yet I am fairly confident that the code above could serve as a driver for this process. Why? Because it is written at a high level, that allows it to direct the process while leaving implementation detail to the fuctions that it calls. That is the magic of structured programming. It allows you to focus on one level of abstraction at a time. HTH, Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>