Hi,

Suggested correction to perlintro in perl v5.8.1.

Now:

 Parentheses for capturing
           As well as grouping, parentheses serve a second pur­
           pose.  They can be used to capture the results of
           parts of the regexp match for later use.  The results
           end up in $1, $2 and so on.

               # a cheap and nasty way to break an email address up into parts

               if ($email =~ /([EMAIL PROTECTED])+@(.+)/) {
                   print "Username is $1\n";
                   print "Hostname is $2\n";
               }

Gives the wrong Username, only one letter.

Should be?

 Parentheses for capturing
           As well as grouping, parentheses serve a second pur­
           pose.  They can be used to capture the results of
           parts of the regexp match for later use.  The results
           end up in $1, $2 and so on.

               # a cheap and nasty way to break an email address up into parts

               if ($email =~ /([EMAIL PROTECTED])+@(.+)/) {
                   print "Username is $1\n";
                   print "Hostname is $2\n";
               }


- Jostein

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to