Scott Batchelor wrote:
> 
> Ok,   Sorry guys I am trying to get my head around this...
> 
> $pair=~m/([^=]+)=(.*)/)
> 
> The "m" means treat string as multiple lines

No, m/regex/ and /regex/ mean the same thing.  The "m" is usually used
if you use different delimiters for the regex, for example: m!regex!,
m%regex%, m[regex], etc...  The "m" option for multiple lines (as with
all options) goes at the end. /^regex/m - match at the beginning of a
line in the string.


> Then we are grouping with a parenthesis and the "^=" is saying matching
> anything up to the "="

The "^=" is inside a character class [^=].  The caret (^) at the start
means to use the complement of the following characters.  In other words
all characters except "=".


> The "+" is a quantifier saying that must match 1 or more times...

Yes.

> Then the the rest is saying match anything after the "="

(.*) means to match any character, except a newline, zero or more
times.  If you want "." to match a newline as well then you need the /s
option (at the end.)

> I guess my question is am I right?
> 
> And I still am not sure where it is saying to assign the first match to
> variable $1 and then the rest to variable $2

The regular expressions inside the parenthesis automatically assign to
the numeric scalar variables.

/((ab)cd)(ef(gh))/
$1 = 'abcd'
$2 = 'ab'
$3 = 'efgh'
$4 = 'gh'


HTH
John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to