Hi, there.
Supose that I have the following lines:
my $l = <FILE0> // <FILE1> // <FILE2>;
chomp $l;
Does that mean that in the first line there are performed
a line read in various files or just the first one, FILE0
if it's true what it returns?
Thanks in advance.
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;
Does that mean that in the first line there are performed
a line read in various files or just the first one, FILE0
if it's true what it returns?
Thanks in advance.
Hi gamo,
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.
See https://perldoc.pl/perlop#Logical-Defined-Or
Hope that helps,
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.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 296 |
Nodes: | 16 (2 / 14) |
Uptime: | 62:35:01 |
Calls: | 6,654 |
Files: | 12,200 |
Messages: | 5,331,627 |