in reply to Re: Sorting file rows and copy them in an array
in thread Sorting file rows and copy them in an array

Hi,
First, What does the /g modifier mean?
Secondly, what does the [0] mean?

saverio
  • Comment on Re^2: Sorting file rows and copy them in an array

Replies are listed 'Best First'.
Re^3: Sorting file rows and copy them in an array
by choroba (Cardinal) on Dec 11, 2014 at 16:00 UTC
    1. /g means "global". See perlop as already hinted.
      The /g modifier specifies global pattern matching—that is, matching as many times as possible within the string. How it behaves depends on the context. In list context, it returns a list of the substrings matched by any capturing parentheses in the regular expression. If there are no parentheses, it returns a list of all the matched strings, as if there were parentheses around the whole pattern.
    2. (...)[0] returns the first (zeroth) element of the list. Therefore, the construct enforces list context on the contents of the parentheses.
    لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
Re^3: Sorting file rows and copy them in an array
by Anonymous Monk on Dec 11, 2014 at 15:59 UTC