Google Группы больше не поддерживают новые публикации и подписки в сети Usenet. Опубликованный ранее контент останется доступен.

[perl #40816] open opcode creates file if it doesn't exist

8 просмотров
Перейти к первому непрочитанному сообщению

Jonathan Rockway

не прочитано,
11 нояб. 2006 г., 14:53:2811.11.2006
– bugs-bi...@rt.perl.org
# New Ticket Created by Jonathan Rockway
# Please include the string: [perl #40816]
# in the subject line of all future correspondence about this issue.
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=40816 >


Not sure if this is a bug or not, but I noticed that the open opcode
creates its argument if the desired file doesn't exist. Here's a test
case:

.sub main :main
.param pmc args
.local pmc file
$S0 = shift args # script name
$S0 = shift args # first argument
file = open $S0
end
.end

Run as "parrot test.pir <filename>". If filename doesn't exist, it
will be created.

BTW, this is my first PIR script, so please be gentle :)

Regards,
Jonathan Rockway

jnthn@jnthn.net via RT

не прочитано,
16 дек. 2006 г., 13:55:1616.12.2006
– perl6-i...@perl.org
On Sat Nov 11 11:53:27 2006, j...@jrock.us wrote:
> Not sure if this is a bug or not, but I noticed that the open opcode
> creates its argument if the desired file doesn't exist.
>
There are two variants of the open opcode: this one, and one where you
can specify a mode. The default open mode at the moment is "+<" - that
is, open for read and create it if it doesn't exist. You can specify
another operand to open specifying the open mode "<" instead, which will
just open the file and not create it.

So, I think this is not a bug - yes, we could argue all day about what
the default open mode should be, but there's a perfectly good way to be
explicit about you want that's only a few characters to type. :-)

Jonathan

Jerry Gay

не прочитано,
18 дек. 2006 г., 12:00:1518.12.2006
– parrotbug...@parrotcode.org, perl6-i...@perl.org
pardon my ignorance, because i haven't checked the documentation, but
is the behavior in the last paragraph documented? arguably, it is a
bug in the C<open> documentation unless that opcode it is described as
defaulting to '+<'.
~jerry
0 новых сообщений