in reply to Re: Returning Array
in thread Returning Array
Depending on where in the rest of the code @L1 lives, this would or wouldn't fail to compile under strictures. But let's say, for the sake of argument, that @L1 lives in a scope that encompasses the subroutine. What do you think that @L1 will contain by the time the foreach loop is done? That is, what do you think this subroutine will return?
Valid answers are:
- The first line that matched /notice/ and /rdy/ - the first time @L1 was set, it was to that line, so it's gonna stick, right? You always remember your first time.
- The last line that matched /notice/ and /rdy/ - the last time @L1 was set, it was set to that line, so that's what's gonna stick, right?
- All lines that matched /notice/ and /rdy/ - each time a line matched, the line got put into @L1, which is an array, which can hold multiple pieces of data, so @L1 remembers all those lines that matched, right?
<Reveal this spoiler or all in this thread>
|
---|
In Section
Seekers of Perl Wisdom