Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2005
    Posts
    220

    Unanswered: Help with expression

    I am rather new to Perl. Can someone tell me what this line is doing?

    if (($hh, $mm) = ($newdi{$dlr}{p_difexpectedtime} =~ /(\d+)\d+)/))

  2. #2
    Join Date
    Feb 2006
    Posts
    56
    Quote Originally Posted by ssmith001
    I am rather new to Perl. Can someone tell me what this line is doing?

    Code:
     if (($hh, $mm) = ($newdi{$dlr}{p_difexpectedtime} =~ /(\d+):(\d+)/))
    It's seeing if $newdi{$dlr}{p_difexpectedtime} matches a pattern of one or more digits (\d+) followed by a colon followed by one or more digits. If the match is true the values of the digits are stored in pattern memory which is what the () are for in the regexp ($1 and $2 respectively) and those values are passed as a list and stored in the two scalars on the left side of the = sign. $hh will hold the first (\d+) found in the string ($1) and $mm will hold the second (\d+) found in the string ($2).

  3. #3
    Join Date
    Sep 2005
    Posts
    220
    Thanks for the clarification

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •