in reply to Re: Understanding -> function
in thread Understanding -> function

Thanks Monks.. The formatting code will be below where there will be $1, $2 and $3 values.
( /^BAK(\w+)\s+(\d+)\s+([\w\_]+)\s*/i )
But I still do not understand the use of =$1; and $3; at end of code for below two lines.
$bakjobs->{"$2"}{"dbt"} = $1; $bakjobs->{"$2"}{"cdt"} =$3;
Please explain.. Appreciate your help..

Replies are listed 'Best First'.
Re^3: Understanding -> function
by plobsing (Friar) on Dec 28, 2008 at 20:31 UTC

    That's an assignment. It puts the value of $1 into $backjobs->{$2}{dbt}. Likewise, it puts the value of $3 into $bakjobs->{$2}{cdt}.

    Also note that \w matches underscores, so the character class in the regex is redundant. See perlretut.

Re^3: Understanding -> function
by AnomalousMonk (Archbishop) on Dec 29, 2008 at 00:33 UTC
    $1, $2, $3 and so on are capture variables.

    Specifically, in the regex
        /^BAK(\w+)\s+(\d+)\s+([\w\_]+)\s*/i
    the sub-expressions (\w+), (\d+) and ([\w\_]+) (which, as already noted, is the same as (\w+) since \w is [a-zA-Z0-9_], but under the control of locale) are capturing groups, and whatever these groups match, if anything, is available through the capture variables. See perlre, perlretut (especially Extracting matches) and perlrequick for further discussion of capturing groups and capture variables; in particular, how the number of the variable ($1, $2, $3, etc.) relates to the order of the capture group in the regex.