Quoth jvromans@squirrel.nl (Johan Vromans):
>
> The question remains to what level it must be compatible with the
> current <> implementation. When a file list is passed, I'd say that
> @ARGV should remain untouched. But should ARGV, $ARGV and ARGVOUT
> still reflect the status of the iterator, as they do with <> ?
No, certainly not. However, given that the iterator is an object,
something like this should be possible:
my $it = Iterator::Files->new(files => \@files, inplace => '.bak');
while (<$it>) {
print "current line: $_";
print 'current filename: ' . $it->file;
print 'current line: ' . $it->line; # same semantics as $.
print 'current output filename: ' . $it->output;
}
You could also make the iterator object itself a blessed glob, so that
print $it "foo";
becomes the equivalent of
print ARGVOUT "foo";
(If you were feeling *really* clever, you could create a glob with IoIFP
and IoOFP different, so that
getc $it;
read from the input file and
print $it "foo";
wrote to the output file :) ).
Ben
--
You poor take courage, you rich take care:
The Earth was made a common treasury for everyone to share
All things in common, all people one.
'We come in peace'---the order came to cut them down. [ben@morrow.me.uk]