> El 13/2/21 a las 5:41, Athanasius escribió:
>> On 13/02/2021 11:42 am, gamo wrote:
>>> Hi, there.
>>> Supose that I have the following lines:
>>> my $l = <FILE0> // <FILE1> // <FILE2>;
>>> chomp $l;
>> The logical defined-OR operator // is left-associative and
>> it short-circuits. So, if <FILE0> returns a defined value,
>> that is assigned to $l and no further lines are read.
>> But if <FILE0> returns an undefined value, <FILE1> is called.
>> Again, if it returns a defined value, that is assigned to $l
>> and the last file is not read; but if it returns an undefined
>> value, <FILE2> is called and the result of that line-read is
>> assigned to $l.
> That's wonderful. It's just the result that I desire, to open
> various files and read all lines and files in that order.
If you don't mind reading all file data into memory upfront, you could
also use a list of handles evaluate in list conext.
my ($fhg, $fhp);
open($fgh, '<', '/etc/passwd');
open($fhp, '<', '/etc/group');
print $_ for <$fhg>, <$fhp>;