Re: virtual file concatenation
- From: "John W. Krahn" <someone@xxxxxxxxxxx>
- Date: Mon, 19 Feb 2007 23:47:46 GMT
xhoster@xxxxxxxxx wrote:
When refactoring code to read from more than one file in sequence, I will
occasionally use somthing like this, which works but makes me
feel dirty:
open my $fh, "cat file1 file2 file3 |" or die $!;
while(<$fh>) {
@ARGV = qw/ file1 file2 file3 /;
while ( <> ) {
I'd rather virtually concatenate file handles, like this:
## $fh1 $fh2 $fh3 are already open read handles
my $fh= IO::Something->new($fh1,$fh2,$fh3);
while (<$fh>) {
for my $fh ( $fh1, $fh2, $fh3 ) {
while ( <$fh> ) {
John
--
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order. -- Larry Wall
.
- References:
- virtual file concatenation
- From: xhoster
- virtual file concatenation
- Prev by Date: virtual file concatenation
- Next by Date: Re: Installation problem with CORBA::omniORB
- Previous by thread: virtual file concatenation
- Index(es):
Relevant Pages
|
|