If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Perl and the DBI > Help with expression

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-03-06, 17:16
ssmith001 ssmith001 is offline
Registered User
 
Join Date: Sep 2005
Posts: 220
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+)/))
Reply With Quote
  #2 (permalink)  
Old 05-03-06, 17:32
KevinADC KevinADC is offline
Registered User
 
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).
Reply With Quote
  #3 (permalink)  
Old 05-03-06, 17:41
ssmith001 ssmith001 is offline
Registered User
 
Join Date: Sep 2005
Posts: 220
Thanks for the clarification
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On