in reply to What does this regex do?

It should (assuming a match) capture a series of values from $file into the array @cvs. The matching occurs like this (explanation brought to you by YAPE::Regex::Explain):

The regular expression: (?s-imx:((?:(?:[^\n@]+|@[^@]*@)\n?)+)) matches as follows: NODE EXPLANATION ---------------------------------------------------------------------- (?s-imx: group, but do not capture (with . matching \n) (case-sensitive) (with ^ and $ matching normally) (matching whitespace and # normally): ---------------------------------------------------------------------- ( group and capture to \1: ---------------------------------------------------------------------- (?: group, but do not capture (1 or more times (matching the most amount possible)): ---------------------------------------------------------------------- (?: group, but do not capture: ---------------------------------------------------------------------- [^\n@]+ any character except: '\n' (newline), '@' (1 or more times (matching the most amount possible)) ---------------------------------------------------------------------- | OR ---------------------------------------------------------------------- @ '@' ---------------------------------------------------------------------- [^@]* any character except: '@' (0 or more times (matching the most amount possible)) ---------------------------------------------------------------------- @ '@' ---------------------------------------------------------------------- ) end of grouping ---------------------------------------------------------------------- \n? '\n' (newline) (optional (matching the most amount possible)) ---------------------------------------------------------------------- )+ end of grouping ---------------------------------------------------------------------- ) end of \1 ---------------------------------------------------------------------- ) end of grouping ----------------------------------------------------------------------

The preceeding explanation is the output from the following test code:

use warnings; use strict; use YAPE::Regex::Explain; my $REx = qr/((?:(?:[^\n@]+|@[^@]*@)\n?)+)/s; print YAPE::Regex::Explain->new($REx)->explain;

When deciphering a regular expression, it's often helpful to use the /x modifier so you can lay the regular expression out in smaller chunks that are easier to digest.

my $REx = qr/ ( (?: (?: [^\n@]+ | @ [^@]* @ ) \n? )+ ) /gsx;

Dave