thanks a lot frank......i think i hav got the thing. Regards
Saurabh --- Frank Wiles <[EMAIL PROTECTED]> wrote: > .------[ Saurabh Singhvi wrote (2003/06/05 at > 07:57:14) ]------ > | > | well i cant understand what the $1, $2 and $3 > do?? > | herez the code > | > | #!/usr/local/bin/perl -w > | > | # Get the date in the standard date format. (ex: > Tue > | Oct 24 19:03:03 > | 1995 ) > | my $date = localtime(); > | > | # Search through the date looking for the hour, > | minute, and second. > | if ($date =~ /(\d\d):(\d\d):(\d\d)/) > | { > | # Save the information. > | my $hours = $1; > | my $minutes = $2; > | my $seconds = $3; > | print "Hours : $hours \n"; > | print "Minutes: $minutes \n"; > | print "Seconds: $seconds \n"; > | } > | > `------------------------------------------------- > > In the regular expression: > > $date =~ /(\d\d):(\d\d):(\d\d)/ > > What is happening is that it is looking for > three sets of two digits > each, separated by colons. Because the digits > are enclosed in > parenthesis they are "grabbed" by the regex > engine and stored into > the enumerated variables $1, $2, and $3... from > left to right. > > The if() block is executed because the regular > expression returns > true if it finds a suitable match. > > So if $date contained: > > Thu Jun 5 10:04:03 CDT 2003 > > $1 would contain '10'. > $2 would contain '04'. > $3 would contain '03'. > > Hope this helps. > > --------------------------------- > Frank Wiles <[EMAIL PROTECTED]> > http://frank.wiles.org > --------------------------------- > ===== @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ SAURABH SINGHVI H-8,ROOM NO.291 IIT BOMBAY POWAI MUMBAI @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ __________________________________ Do you Yahoo!? Yahoo! Calendar - Free online calendar with sync to Outlook(TM). http://calendar.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]