Reputation: 81
I'm trying to convert a line of old code from C (which I do not know) to Perl (which I sorta know).
It has a data structure I don't understand, that being a number followed by /* character */
if (lSeries != 18 /*S*/ && lSeries != 2 /*C*/ && lSeries != 4 /*E*/ && lSeries != 6 /*G*/) {}
Upvotes: 1
Views: 94
Reputation: 118605
In C, the /* ... */
construction indicates a comment. It will not be compiled or executed by the program.
So the executable part of that code snippet is
if (lSeries != 18 && lSeries != 2 && lSeries != 4
&& lSeries != 6) {}
A literal translation to Perl would be
if ($lSeries != 18 && $lSeries != 2 && $lSeries != 4
&& $lSeries != 6) { }
Upvotes: 5
Reputation: 302
/* C style for multiline comments */
C code:
if( lSeries != 18 /*S*/
&& lSeries != 2 /*C*/
&& lSeries != 4 /*E*/
&& lSeries != 6 /*G*/
) {}
#perl style for single line comments. for more please refer Acme::Comment
Perl Code:
if( $lSeries != 18 #S
&& $lSeries != 2 #C
&& $lSeries != 4 #E
&& $lSeries != 6 #G
) {}
Upvotes: 5