On Tue, Jul 13, 2004 at 03:41:54PM +0200, Michele Dondi wrote:
> On Tue, 13 Jul 2004 [EMAIL PROTECTED] wrote:
>
> > I have a wish for Perl 6. I would like if the open-funktion
> > opens only a file if it doesn't exist.
> > Of course, I can first test if the file exist.
>
> I rather have a much "bigger" wish for an open-like operator that to be
> fair I would like to see *also* in Perl5: nothing that one can do in well
> more than one way in any case (also including creating a module that will
> do exactly what I write below...), but that indeed would come handy
> occasionally.
>
> I'm thinking of an operator that returns a "magical" FH working like the
> ARGV one (with authomatic error handling etc. - obviously under Perl6
> the beahviour could be tunable by means of modifiers, etc.), e.g.
>
> openmany my $fh, [list];
> while (<$fh>) {
> # ...
> }
>From your description, it sounds like this is what you want:
{
local @ARGV = qw(foo bar baz and some other files);
while (<>) {
# ... ARGV and friends are at your disposal
}
}
I suppose the perl6 equivalent would be:
{
temp $*ARGS = <<foo bar baz and some other files>>;
while (<$ARGS>) {
# ...
}
}
Not much different is it?
-Scott
--
Jonathan Scott Duff
[EMAIL PROTECTED]