in reply to meaning for the code

can any one explain me what the following code do.    ($whole,$deci) = /(?:(\d*)\.?(\d+))|(?:(\d+)\.?(\d*))/;

Yes.    The pattern matches either (\d*)\.?(\d+) or (\d+)\.?(\d*).    The variable $whole is assigned the contents of the first set of capturing parentheses ((\d*) or (\d+)) and the variable $deci is assigned the contents of the second set of capturing parentheses ((\d+) or (\d*)).

Update: Thanks ikegami.    It looks like I couldn't get anything right yesterday.    :-(

Replies are listed 'Best First'.
Re^2: meaning for the code
by ikegami (Patriarch) on Mar 12, 2008 at 17:10 UTC

    No way!

    The variable $whole is assigned the contents of the first set of capturing parentheses (the first (\d*)).
    The variable $deci is assigned the contents of the second set of capturing parentheses (the first (\d+)).

    /(?:(\d*)\.?(\d+))|(?:(\d+)\.?(\d*))/ ^^^^^ ^^^^^ Always Always $whole $deci

    Should the second alternation match — it never will — then $whole and $deci will be undef.