in reply to Re: japh with re
in thread japh with re

These explanations refer to the numbered items in the "above" post. Hope they help. :-)

  1. The four characters are treated as a string. Performing math on it converts it back to decimal, so "0100" * 1 = 100.

  2. I thought I'd exploit the short-cuts available in the logical operators to effect an if-then-else statement. "And" evaluates the right side only if the left side is true. "Or" evaluates the right side only if the left side is false. So,
    $a && $b || $c

    will evaluate pretty much to the same thing as

    if($a) { $b; } else { $c; }

  3. The do{} is a block of code executed for each element in the "for" statement modifier. I use it to contain the print...while statement. Inside the braces, the while is a modifer for the print statement. Outside the braces, it would modify the do{} block.

  4. Yes. See above.

  5. The \G saves the point of last match, so when you go to match again (continuing the global match) it picks up where it left off. It would be like chopping off everything before the point where \G is, and then trying to match /^(....)/. Now, I don't see any allowance for spaces in that, so, no, it won't skip the spaces.

    Hope this helped, -v
    "Perl. There is no substitute."