CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
A question about groups in regular expressions

 



moroshko
Novice

Jun 1, 2008, 11:58 AM

Post #1 of 1 (393 views)
A question about groups in regular expressions Can't Post

Can someone tell me please why in the following program $1 is not defined ? I thought that every group (every pair of parentheses) is going to $1, $2, $3 and so on.
Where am I wrong ?
Which pairs of parentheses are going to $1, $2, $3, ... ?
Thanks in advance !!


$_ = "a bc";

if (/(bc)?/) {
print "\$1 = [$1]\n" if (defined $1);
} else {
print "No match !";
};

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives