Re: while reading 'mastering perl' @+ and @-, not too clear on this

2008-03-23 Thread brian d foy
In article <[EMAIL PROTECTED]>, Richard Lee <[EMAIL PROTECTED]> wrote: > While reading 'mastering perl', I run into @- and @+ for the first time. > Trying to understand what's going on, I ran the code from the book, but > > $-[1] and $+[1] shoudln't match only the first match? (in this case, > sh

Re: while reading 'mastering perl' @+ and @-, not too clear on this

2008-03-19 Thread Richard Lee
John W. Krahn wrote: Richard Lee wrote: Thanks John for detailed explanation!! I just dont' understand why \ (also didn't know that within [ ], \ has to be escaped.) needs to be watch out for within " " .. \ use can be tricky, for example: $ perl -le"print 'hello'" hello $ perl -le"print '

Re: while reading 'mastering perl' @+ and @-, not too clear on this

2008-03-18 Thread John W. Krahn
Richard Lee wrote: Thanks John for detailed explanation!! I just dont' understand why \ (also didn't know that within [ ], \ has to be escaped.) needs to be watch out for within " " .. \ use can be tricky, for example: $ perl -le"print 'hello'" hello $ perl -le"print 'he\llo'" he\llo $ perl

Re: while reading 'mastering perl' @+ and @-, not too clear on this

2008-03-18 Thread Richard Lee
John W. Krahn wrote: Richard Lee wrote: Took your advice and start to read 'Mastering regular expression' by Jeffrey E.F.Friedl, Can you explain below further? on page, 205 push(@fields, $+) while $text =~ m{ "([^\"\\]*(?:\\.[^\"\\]*)*)",? #standard quoted string(with possible co

Re: while reading 'mastering perl' @+ and @-, not too clear on this

2008-03-18 Thread John W. Krahn
Richard Lee wrote: Took your advice and start to read 'Mastering regular expression' by Jeffrey E.F.Friedl, Can you explain below further? on page, 205 push(@fields, $+) while $text =~ m{ "([^\"\\]*(?:\\.[^\"\\]*)*)",? #standard quoted string(with possible comma) | ([^,]+),?

Re: while reading 'mastering perl' @+ and @-, not too clear on this

2008-03-17 Thread Richard Lee
Say you have the string "abcdefghi". The positions in the string are: a b c d e f g h i ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ 0 1 2 3 4 5 6 7 8 9 If you have the regular expression: /(de)/ Then the match starts at position 3, moves forward two characters, and ends at position 5, where the next match, i

Re: while reading 'mastering perl' @+ and @-, not too clear on this

2008-03-16 Thread Richard Lee
Rob Dixon wrote: Richard Lee wrote: Rob Dixon wrote: Perhaps it would help to think of the offset as being the index of the points between the characters, so the start of the string is at offset zero, after 'a' (and before 'b') is at offset one and so on. Then can you see how offset 7 is befor

Re: while reading 'mastering perl' @+ and @-, not too clear on this

2008-03-16 Thread Rob Dixon
Richard Lee wrote: Rob Dixon wrote: Perhaps it would help to think of the offset as being the index of the points between the characters, so the start of the string is at offset zero, after 'a' (and before 'b') is at offset one and so on. Then can you see how offset 7 is before 'hi' and offset

Re: while reading 'mastering perl' @+ and @-, not too clear on this

2008-03-16 Thread John W. Krahn
Richard Lee wrote: John W. Krahn wrote: Richard Lee wrote: While reading 'mastering perl', I run into @- and @+ for the first time. perldoc perlvar Trying to understand what's going on, I ran the code from the book, but $-[1] and $+[1] shoudln't match only the first match? (in this case,

Re: while reading 'mastering perl' @+ and @-, not too clear on this

2008-03-16 Thread Richard Lee
Rob Dixon wrote: Richard Lee wrote: John W. Krahn wrote: Richard Lee wrote: While reading 'mastering perl', I run into @- and @+ for the first time. perldoc perlvar Trying to understand what's going on, I ran the code from the book, but $-[1] and $+[1] shoudln't match only the first mat

Re: while reading 'mastering perl' @+ and @-, not too clear on this

2008-03-16 Thread Rob Dixon
Richard Lee wrote: John W. Krahn wrote: Richard Lee wrote: While reading 'mastering perl', I run into @- and @+ for the first time. perldoc perlvar Trying to understand what's going on, I ran the code from the book, but $-[1] and $+[1] shoudln't match only the first match? (in this case,

Re: while reading 'mastering perl' @+ and @-, not too clear on this

2008-03-16 Thread Richard Lee
John W. Krahn wrote: Richard Lee wrote: While reading 'mastering perl', I run into @- and @+ for the first time. perldoc perlvar Trying to understand what's going on, I ran the code from the book, but $-[1] and $+[1] shoudln't match only the first match? (in this case, shoudln't it be, 7 t

Re: while reading 'mastering perl' @+ and @-, not too clear on this

2008-03-16 Thread John W. Krahn
Richard Lee wrote: While reading 'mastering perl', I run into @- and @+ for the first time. perldoc perlvar Trying to understand what's going on, I ran the code from the book, but $-[1] and $+[1] shoudln't match only the first match? (in this case, shoudln't it be, 7 to 8 ?, instead of 7 to