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 confusing set of character

 



boonflies
New User

Apr 23, 2017, 9:44 PM

Post #1 of 2 (750 views)
A confusing set of character Can't Post

I am trying to understand perl with a working program. I got stuck at place where I found,

elsif (/\.?(?:.*\.)+(.*)/)

can that be broken down to understand?


Laurent_R
Veteran / Moderator

Apr 23, 2017, 11:20 PM

Post #2 of 2 (748 views)
Re: [boonflies] A confusing set of character [In reply to] Can't Post

It is called a regular expression and it is trying to match$_ to the pattern. This looking into $_ for:

Code
/     start of regex 
\.? zero or one literal dot
(?:.*\.)+ a group occurring one of more time (see below)
(.*) a capture group capturing any number
of any characters until the end of the line
/ end of regex

The first group consists of: any number of any characters (except new line) followed by a literal dot.

Overall, this seems to be looking for file and directory names and trying to capture the extension.

 
 


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

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