|We don't bite newbies here... much|
Re: Check remote file for size?by pjf (Curate)
|on Oct 13, 2001 at 12:22 UTC||Need Help??|
Firstly, I'd strongly suggest you consider using the CGI perl module, which will do QUERY_STRING decoding for you. It comes standard with perl, provides many very useful features, and will do a better job than your home-grown encoding (particularly for things like parameters with multiple values).
To answer your question about checking a file's size, you can use the -s operator, like this:
-s returns the file size in bytes if you need that much information.
In your particular example, I would suggest opening your file for writing using open(FILE,">$filename"). The ">" will clobber the contents of the file if it exists, as opposed to ">>" which will append to the file. Clobbering the contents means you shouldn't need to care about the file size at all.
Also, there's nothing wrong with using perl modules. In fact, it's very highly recommended. More often than not, re-inventing the wheel results in something which isn't quite as round.
If you're looking at stripping out HTML tags, I'd suggest looking at HTML::Parser, which will do most of the work for you.
If you want your script to die automatically after a certain period of time, you can set an alarm. Unfortunately I don't know how portable this is across non-UNIX operating systems.
If you want your code to always clean up after itself, you can do so with an END block.
An END block runs just before the perl interpretor exits.
Hope that you find all of the above useful.