in reply to Understanding -> function

see:

The sub cdtcall gets a reference to the %bakjobs hash as an argument and stores it in scalar $bakjobs. Note: %bakjobs and $bakjobs are different variables despite their similar looking names.

Well, $bakjobs is a reference to a hash. $bakjobs->{"$2"} returns a value of a key "$2" for that hash. This value is a hash reference again. And $bakjobs->{"$2"}{"dbt"} is an accessor to value of "dbt" key of %{$bakjobs->{"$2"}} hash.

Replies are listed 'Best First'.
Re^2: Understanding -> function
by John007 (Acolyte) on Dec 28, 2008 at 19:51 UTC
    Many Thanks for this help,
    Appreciate your further help..
    ** I understood that $bakjobs->{"$2"} takes value of $2 for hash %bakjobs and store it.
    ** I further understood that {"dbt"} becomes key of %{$bakjobs-> {"$2}.
    Then
    (1) what is the use of =$1 and =$3 at end of code?
    (2) This means the %bakjobs will have two different keys one as "dbt" and other as "cbt"
    $bakjobs->{"$2"}{"dbt"} = $1; Thanks in advance..
      $bakjobs is a reference to the hash %bakjobs. The $bakjobs->{"$2"} part is accessing the "$2" key of that hash. The added {"dbt"} takes the value of the "$2" key and interprets it as a reference to another hash (creating one if necessary) and the = $1; stores $1 as the value for the "dbt" key in that inner hash. So if the line being parsed was BAKfoo bar, %bakjobs looks something like this (in addition to anything else already in it):
      %bakjobs = ( "foo" => { "dbt" => "bar", "cdt" => undef, } );
      (The value for cdt is undef from $3 because there are only two sets of capturing parentheses in your regex.)