in reply to Re: Re: Compressed content module
in thread Compressed content module

Doh! I forgot about File and friends. That is one way for the user to do so, and a good one too. I'd actually slightly mangled the module logic in my head there (the test for gz suffix). I'd recommend giving an example of that in the documentation (BTW MS uses CHTML for compiled HTML, there's also cHTML - compact HTML). Also, you might want to remove the test for gz extension and look for magic a la file(1). It's more UN*Xy, even if it is more expensive.

--
I'm not belgian but I play one on TV.

Replies are listed 'Best First'.
Re^4: Compressed content module
by diotalevi (Canon) on Dec 01, 2002 at 23:18 UTC

    GZip magic is easy - The first two bytes are "\x1f\x8b". You can also check for compress which I recall is "\x1f\x9b" though you may want to check.

    __SIG__ use B; printf "You are here %08x\n", unpack "L!", unpack "P4", pack "L!", B::svref_2object(sub{})->OUTSIDE;
      'easy ' ne 'cheap'. It is certainly easy (thanks for the magic), but it's more expensive than doing an rindex on the filename.

      --
      I'm not belgian but I play one on TV.

        And I thought you'd just suggesting running file(1) on the file. So between a call to file(1) and just reading the first two bytes which are going to be read anyway... I don't see how that's particularly expensive. But then all this only applies if you want to detect GZip/compress files which don't use a .gz/.Z extension.

        __SIG__ use B; printf "You are here %08x\n", unpack "L!", unpack "P4", pack "L!", B::svref_2object(sub{})->OUTSIDE;