This is not a regular expression, but rather what is know as the "ternary 
operator".  It is a terse way of writing an if-else statement with variable 
assignment.  In this case, it is the equivalent of writing:

if (!X) {

  X = 2;

} else {

  X = X;

}

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of
lorid
Sent: Thursday, March 10, 2005 5:02 PM
To: perl-win32-users
Subject: simple reg ex


I know this is perl not javascript, I thought I was good at deciphering reg ex
but the 2nd line in this function has got me puzzled.
Can anyone decipher:
  X = (!X ? 2 : X);



function round(number,X) {
> > // rounds number to X decimal places, defaults to 2
> > X = (!X ? 2 : X);
> > return Math.round(number*Math.pow(10,X))/Math.pow(10,X);
> > }

thanks
lori

_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to