kirbyk has asked for the wisdom of the Perl Monks concerning the following question:
I want to detect if the file they've uploaded is binary or text only, and give the user a helpful error message. (Like, if they upload a .xls file.) Note that the file never exists on a filesystem, so I can't use any unix tricks (and I don't want to write out a temp file.)
I figure I can go character-by-character in a loop and look at the ascii values, but that seems horribly inefficient. Is there a quick regex that could do this check? I'm not worried about Unicode characters, but it'd be nice if extended ascii characters through, say, 165 (to get all the accented characters.)
-- Kirby, WhitePages.com
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Detecting 'binary' in a variable
by Transient (Hermit) on Jul 05, 2005 at 17:49 UTC | |
by dbwiz (Curate) on Jul 05, 2005 at 18:19 UTC | |
by Transient (Hermit) on Jul 05, 2005 at 18:23 UTC | |
by dbwiz (Curate) on Jul 05, 2005 at 18:31 UTC | |
by Transient (Hermit) on Jul 05, 2005 at 18:36 UTC | |
by kirbyk (Friar) on Jul 05, 2005 at 18:01 UTC | |
Re: Detecting 'binary' in a variable
by brian_d_foy (Abbot) on Jul 05, 2005 at 18:01 UTC |