The value of the flip-flop regex returns a line number like: 1,2,3,4E0 and that number can be tested in another regex.#!/usr/bin/perl -w use strict; use Data::Dumper; my @list= ("a".."c","DBIC","A".."C","DANCER","a".."c"); my @result; for (@list) { push @result,$_ if /DBIC/.. /DANCER/ and ! // } print Dumper \@result; # uses http://www.perlmonks.org/?node_id=525392 my @result2 = grep { (/DBIC/.. /DANCER/) =~ /^\d+(?<!^1)$/ }@list; print Dumper \@result2; __END__ $VAR1 = [ 'A', 'B', 'C' ]; $VAR1 = [ 'A', 'B', 'C' ];
As another note this "xE0" notation is used in other places in Perl. For example, the DBI can return 0E0 as the number of results which is 0 * 10**0 or numeric zero (0 * 1) although this evaluates to "true" when tested in a logical sense, meaning that that the statement "worked" but returned no results (numeric value is zero). Here the line number ending in E0 is the "last one". This is clever but it works.
In reply to Re: Bug with "last successfully matched regular expression" (empty regex)
by Marshall
in thread Bug with "last successfully matched regular expression" (empty regex)
by LanX
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |