2008/7/28 Abigail <abigail@abigail.be>:
>> You suggested that an 'ordinary user' of a program that happens to be
>> written in perl and using <> might start to rely upon the magic
>> behaviour. But this seems to me unlikely if the magic is not
>> mentioned in the program's documentation (and it never is). Only
>> someone who already knew perl would do so. (Indeed, someone who knew
>> more about the behaviour of <> than the original programmer knew, or
>> at least documented.) And most of the time, I would expect people to
>> prefer the shell's standard facilities for redirecting input from a
>> pipeline, which work with all programs.
>
>
> The shell is only an option if the shell is involved. And even if there's a
> shell, such constructs aren't always that portable.
>
>
> I remain of the opinion that p5p has always been quite careful about breaking
> backwards compatability, bending over backwards to avoid breaking even the
> most obscure construct. I think 'while (<>)' should keep doing what it has
> done for longer than I can remember (that is, using 2-arg open).
In that case, the choice must be made between changing the default or not.
The only thing that will break is programs that rely on being able to
process command-line arguments like 'ls|'. The only place were I can
imagine that construct used, is complex systems of interdependent
perl+shell scripts.
I've always been a bit uncomfortable with the current magical behaviour,
and that's why I tend to favor a non-compatible change.
We can add a simple way to restore the old behaviour, though : a
command-line flag (-N and -P were suggested as counterparts to -n and
-p. -P was conveniently made free previously:) (Using an environment
variable for that is out of question.)
> And I welcome any construct that uses 3-arg open.
>
> Now, for some shedcolouring: instead of using <<>>, why not allow a
> listing of IO layers between '<' and '>', which would cause the construct
> to automatically open the files with the listed layers? That is,
>
> while (<:utf8>) {
> # Opens files like 'open $fh, "<:utf8", "filename"'
> }
That's an interesting syntax. And moreover, it mostly parses already.
> A lone : could indicate using 3-arg open, without using any PerlIO layers.
>
> while (<:>) {
> # Open files like 'open $fh, "<", "filename"'
> }
--
Backwards compatibility is often incompatible with security.
-- Bruce Schneier,
http://www.schneier.com/blog/archives/2006/08/technological_a_1.html
Thread Previous
|
Thread Next