Mailing List Archive
tlug.jp Mailing List tlug archive tlug Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]Re: [tlug] Re: tlug] Security question with grep/e...
- Date: Wed, 24 Mar 2004 13:11:02 +0900
- From: "Stephen J. Turnbull" <stephen@example.com>
- Subject: Re: [tlug] Re: tlug] Security question with grep/e...
- References: <200403230503.i2N53juu011858@example.com><20040323172515.GA433@example.com>
- Organization: The XEmacs Project
- User-agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Portable Code, linux)
>>>>> "Tim" == Tim Hurman <kano-tlug@example.com> writes: Tim> Would it not be easier just to do this in PERL anyway, here Tim> is my reasoning, No. For most sane people (and Jim is one such), working with Perl involves bowing to the Porcelain God. Case in point: Tim> die unless ($user_str =~ m/^[\w.]+$/); With the single exception of "\]", backslash escapes in a character class are an abomination. (Here you should of course use my title when citing; this is a purely personal opinion and therefore needs all the authority it can muster to become established as Received Truth.) Not to mention that if I grok his post correctly, Jim is working with multilingual files, and the definition of "file character set" and the various character classes is up for grabs. In Jim's case, it's no big deal. But relying on Perl to get this stuff right is going to cost you some day. Multilingual text is hard, and POSIX didn't even try to deal with it (Perl has extensions, but it's based on the POSIX model). BTW, Martin asked what the Python idiom for "die unless" is. It's if not CONDITION: raise UncatchableError The Perl is more expressive, but I prefer programs that are robust to pilot error and even offer sensible advice: try: # using try here allows for multiple error conditions to be # handled in a relatively clear way, and also allows you to throw # to the handler from a subroutine; for this example it's a gilt # lily, of course if not CONDITION (foo): raise CONDITIONError # code protected from failures of CONDITION here except CONDITIONError: print "Your condition (%s) was bar; try bazing the quux." \ % (foo) continue_sensibly () One thing that's nice about Python (and Perl too) compared to (say) C is that _printf is part of the language standard_ and therefore the translator can check types for printf escapes. The C standards people (somewhat pedantically in these late days, but correctly IMHO) take the position that the C standard does _not_ include the standard C library, and therefore C compilers can't assume that printf is printf. This is why the "<<" and ">>" I/O operators of C++ are a big deal, and not just syntactic boogers: because they are operators, the types they can handle are available to the compiler, unlike printf where the operators are buried in a string. Python uses the same strategy (Python 2.x still has printf but it's considered unPythonic). If the LHS of the % operator is a string, it's actually not a string, but a subclass: a printf format spec. OO ru237. -- Institute of Policy and Planning Sciences http://turnbull.sk.tsukuba.ac.jp University of Tsukuba Tennodai 1-1-1 Tsukuba 305-8573 JAPAN Ask not how you can "do" free software business; ask what your business can "do for" free software.
- References:
- [tlug] Re: tlug] Security question with grep/e...
- From: Jim Breen
- Re: [tlug] Re: tlug] Security question with grep/e...
- From: Tim Hurman
Home | Main Index | Thread Index
- Prev by Date: Re: [tlug] Red Hat dropping MySQL
- Next by Date: Re: [tlug] Red Hat dropping MySQL
- Previous by thread: Re: [tlug] Re: tlug] Security question with grep/e...
- Next by thread: Re: [tlug] Re: tlug] Security question with grep/e...
- Index(es):
Home Page Mailing List Linux and Japan TLUG Members Links