Joe Sprankle wrote:
> 
> Hi all,

Hello,

> I am brand new to perl, and programming at that. I'm learning alot from
> Robert's Perl Tutorial and I was hoping someone culd possibly clear up the
> following from the tutorial:
> 
> $_='My email address is <[EMAIL PROTECTED]>.';
> print "Match 1 worked :$1:" if /(<*)/i;

This regular expression matches zero or more consecutive '<' characters
case-insensitively and stores the match in the $1 variable.  Since the
'<' character doesn't have an upper or lower case version the /i option
is not doing anything useful.  Since zero '<' characters will always
match, the regular expression is always true and the statement will
always print.


> $_='<My email address is <[EMAIL PROTECTED]>.';
> print "Match 2 worked :$1:" if /(<*)/i;

Same as above.


> $_='My email address is <[EMAIL PROTECTED]<<<<>.';
> print "Match 3 worked :$1:" if /(<*>)/i;

This regular expression matches zero or more consecutive '<' characters
followed by one '>' character case-insensitively and stores the match in
the $1 variable.  Since neither the '<' or '>' character have an upper
or lower case version the /i option is not doing anything useful.  Since
'>' must match for the regular expression to be true and the '*' is
greedy this will match the longest string of '<' followed by a '>' at
the end of your string.



John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to