On Mon, Dec 24, 2012 at 08:01:11PM +0000, Rob Dixon wrote:
> On 24/12/2012 13:08, Paul Johnson wrote:
> >On Sun, Dec 23, 2012 at 06:57:38PM +0530, punit jain wrote:
> >>I am seeing which lines have both POP and Webmail as below :-
> >>
> >>if( $line =~ /AccessModes\s*=\s*.*(WebMail)*.*(POP).*(WebMail)*.*/ ) {
> >>                             if(defined $2) {
> >>                                 print "$2 $1"."$line"."\n";
> >>                             }
> >>                         }

> Hi Paul
> 
> I think
> 
> >why, having specified what you are searching for, you then ask what was found
> 
> could be expressed better, or at least needs an explanation.

Yes, you're probably correct.

My point was that the captured expressions are constants: "WebMail",
"POP" and "WebMail" again.  So if $1, $2 and $3 are defined then you
already know what their values are.

So, once you know that the regular expression has matched, your only
interest in $1, $2 and $3 is to see whether $1 and $3 are defined which
will tell you the order of the items on the line.  My guess is that this
is not important to know.

So the "specified what you are searching for" part is the constant
captured expressions, and the "ask what was found" bit is examining $1,
$2 and $3.

-- 
Paul Johnson - p...@pjcj.net
http://www.pjcj.net

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to