Line disciplines (was Re: RFC 69 (v3) Standardize input record separator)
[email protected] (Chaim Frenkel) 10 Aug 2000 22:26:59 -0400
| Newsgroups | perl.perl6.language.io |
|---|---|
| Message-ID | <[email protected]> |
I think a more generic approach would be thinking of it as a series of filters. With the :attributes being hints to the open of what to push on the filehandle. This would allow dynamic additino and removal of the filters while the filehandler were still active. The purely open approach would be somewhat more static. The issue would be speed. Adding lots of little pieces of code each of which has bookkeeping overhead (its own plus the perl invocation of the filter) would slow down perl's io famed text processing speed. <chaim> >>>>> "BCW" == Bryan C Warnock <[email protected]> writes: BCW> standard line discipline syntax of :foo, or use something as simple as BCW> a Perl hash, and would not necessarily be limited to the open call. BCW> (This is all a wag, don't take it as gospel.) BCW> So you'd potentially have hints like so: BCW> :bin BCW> :text BCW> :text=ascii BCW> :text=utf8 BCW> :text=utf32 BCW> :text=ebcdic BCW> :text=some_weird_proprietary_format BCW> :block=<size> BCW> :line= BCW> :line=dos BCW> :line=mac BCW> :line=unix BCW> :line=/like, you know?/ BCW> :mod=chomp BCW> :mod=split BCW> :mod=\&do_some_funky_pre_processing BCW> That would allow you to do stuff like the following. BCW> open FOO, "foo_file", :text=ascii, :line=unix, :mod=chomp; BCW> while (<FOO>) BCW> { BCW> # $_ = an ascii line, delimited to \n, but without the \n; BCW> } -- Chaim Frenkel Nonlinear Knowledge, Inc. [email protected] +1-718-236-0183