in reply to Re^2: Extract Multiple Lines from the End of a multi-line string
in thread Extract Multiple Lines from the End of a multi-line string
and also the [0] on the end of the return?
In list context, the match operator returns what it captured. I used a list slice to force list context.
I could also have used$x = 'abc' =~ /a(.)c/; # 1 (or false on fail) @x = 'abc' =~ /a(.)c/; # b (or () on fail) $x = ( 'abc' =~ /a(.)c/ )[0]; # b (or undef on fail)
$x = 'abc' =~ /a(.)c/ && $1; # b (or false on fail)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Extract Multiple Lines from the End of a multi-line string
by NateTut (Deacon) on Oct 17, 2008 at 16:15 UTC | |
by ikegami (Patriarch) on Oct 17, 2008 at 16:58 UTC | |
by NateTut (Deacon) on Oct 17, 2008 at 17:03 UTC | |
by ikegami (Patriarch) on Oct 17, 2008 at 17:09 UTC | |
by NateTut (Deacon) on Oct 17, 2008 at 18:20 UTC |