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: Advanced: Re: [skr302] To print the file in spool with the new format of input file also: Edit Log



FishMonger
Veteran / Moderator

Oct 15, 2015, 6:23 AM


Views: 16720
Re: [skr302] To print the file in spool with the new format of input file also

Others on your cross post thread on perlmonks have given broad explanations on what that section of code is doing. Here's a more detailed explanation of the regex in that unless ($basename =~ ....) statement.


Code
(?-imsx:/^(.{4}|.{10})_(.{10})_(.{8})_(.{6})_(.{10})_(.{8})\.(.{3})(\.gz)?$/) 

matches as follows:

NODE EXPLANATION
----------------------------------------------------------------------
(?-imsx: group, but do not capture (case-sensitive)
(with ^ and $ matching normally) (with . not
matching \n) (matching whitespace and #
normally):
----------------------------------------------------------------------
/ '/'
----------------------------------------------------------------------
^ the beginning of the string
----------------------------------------------------------------------
( group and capture to \1:
----------------------------------------------------------------------
.{4} any character except \n (4 times)
----------------------------------------------------------------------
| OR
----------------------------------------------------------------------
.{10} any character except \n (10 times)
----------------------------------------------------------------------
) end of \1
----------------------------------------------------------------------
_ '_'
----------------------------------------------------------------------
( group and capture to \2:
----------------------------------------------------------------------
.{10} any character except \n (10 times)
----------------------------------------------------------------------
) end of \2
----------------------------------------------------------------------
_ '_'
----------------------------------------------------------------------
( group and capture to \3:
----------------------------------------------------------------------
.{8} any character except \n (8 times)
----------------------------------------------------------------------
) end of \3
----------------------------------------------------------------------
_ '_'
----------------------------------------------------------------------
( group and capture to \4:
----------------------------------------------------------------------
.{6} any character except \n (6 times)
----------------------------------------------------------------------
) end of \4
----------------------------------------------------------------------
_ '_'
----------------------------------------------------------------------
( group and capture to \5:
----------------------------------------------------------------------
.{10} any character except \n (10 times)
----------------------------------------------------------------------
) end of \5
----------------------------------------------------------------------
_ '_'
----------------------------------------------------------------------
( group and capture to \6:
----------------------------------------------------------------------
.{8} any character except \n (8 times)
----------------------------------------------------------------------
) end of \6
----------------------------------------------------------------------
\. '.'
----------------------------------------------------------------------
( group and capture to \7:
----------------------------------------------------------------------
.{3} any character except \n (3 times)
----------------------------------------------------------------------
) end of \7
----------------------------------------------------------------------
( group and capture to \8 (optional
(matching the most amount possible)):
----------------------------------------------------------------------
\. '.'
----------------------------------------------------------------------
gz 'gz'
----------------------------------------------------------------------
)? end of \8 (NOTE: because you are using a
quantifier on this capture, only the LAST
repetition of the captured pattern will be
stored in \8)
----------------------------------------------------------------------
$ before an optional \n, and the end of the
string
----------------------------------------------------------------------
/ '/'
----------------------------------------------------------------------
) end of grouping
----------------------------------------------------------------------



(This post was edited by FishMonger on Oct 15, 2015, 6:23 AM)


Edit Log:
Post edited by FishMonger (Veteran) on Oct 15, 2015, 6:23 AM


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

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