|The stupid question is the question not asked|
'Anonymous' copy via file handle failsby Monk::Thomas (Friar)
|on Jan 16, 2013 at 20:34 UTC||Need Help??|
Monk::Thomas has asked for the
wisdom of the Perl Monks concerning the following question:
(This is part of a larger program. I stripped the code example down.)
I'd like to get a file from somewhere (HTTP, SCP, FTP, local file) and make a local copy via fetch(), pass the file descriptor around, modify the content and later on write the file content to one or more other files.
Alternative a) It would be easy to do this via actual file names but I would like to use open filehandles without an actual filename. This way I wouldn't have to worry about someone tampering with my data while I'm working on it.
Alternative b) I don't want to slurp the file content into main memory.
FETCH The file '/etc/services' has inode 2105201 and size 19398 FETCH The file 'GLOB(0x10c7c78)' has inode 142159 and size 19398 STORE The file 'GLOB(0x10c7c78)' has inode 142159 and size 19398 STORE The file '/tmp/services.d1JH' has inode 142160 and size 0 STORE Copying filehandle tmp1 (GLOB(0x10c7c78)) to tmp2 (/tmp/services.d1JH) file. STORE The file 'GLOB(0x10c7c78)' has inode 142159 and size 19398 STORE The file '/tmp/services.d1JH' has inode 142160 and size 0 -rw------- 1 thomas thomas 0 Jan 16 21:15 /tmp/services_copy
As you can see, the store() function seems to receive the correct data to the file object, but copy does not actually copy the file. I seriously scratched my head on this, but so far no enlightenment has occured. Buffering issue? Copy not happy with the GLOBs? Something totally different?
Time to confess my non-knowledge and ask a senior monk. Hopefully I get something more then just a koan. ;)