This is what I am trying to do: I get the URL of the current page using the DOCUMENT_URI Environment variable, which reads: /product/100.htm. I want to pass the product number, 100, to another page. So I want to parse that variable out of that ENV variable string.
Any help would be greatly appreciated as searching for an answer with google is becoming quite a task on my eyes.
$ENV{REQUEST_URI} =~ /([^\/]+)\.htm/;
my $goo = $1;
This says, find anything preceding ".htm" that is not a slash symbol. Since the slash symbol itself is a special character, it has to be escaped first with a backslash (the same goes for the period in front of "htm"). The caret symbol (^) negates the character class (the "stuff" inside the brackets []). The parentheses around the match pattern says to "return this part" in Perl's specially numbered variables, $1 for the first set of parentheses encountered, $2 for the second (if we had set a second set), etc.