Stack Exchange network consists of 183 Q&A communities includingStack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Visit Stack Exchange//;say$_*2-1,Fizzbuzz for 1..500;<<'}';main(){for(int i=1;i<1001;i++){i%3?printf("%d",i):printf("FizzBuzz");}}Try it online! (C)
Try it online! (Perl)
This hides the Perl code behind a C++ style comment, and the C code inside a Perl here doc, using the final character of the C code as the here doc terminator. The C++ style comment marker looks like an empty regular expression to Perl, which happily executes it, to no visible effect. Just as the here doc which is in void context.
The C version does not print any whitespace, the Perl version prints a newline after eachFizzBuzz.
//;say$_*2-1,Fizzbuzz for 1..500;<<'}';main(){for(int i=1;i<1001;i++){i%3?printf("%d",i):printf("FizzBuzz");}}This hides the Perl code behind a C++ style comment, and the C code inside a Perl here doc, using the final character of the C code as the here doc terminator. The C++ style comment marker looks like an empty regular expression to Perl, which happily executes it, to no visible effect. Just as the here doc which is in void context.
The C version does not print any whitespace, the Perl version prints a newline after eachFizzBuzz.
//;say$_*2-1,Fizzbuzz for 1..500;<<'}';main(){for(int i=1;i<1001;i++){i%3?printf("%d",i):printf("FizzBuzz");}}Try it online! (C)
Try it online! (Perl)
This hides the Perl code behind a C++ style comment, and the C code inside a Perl here doc, using the final character of the C code as the here doc terminator. The C++ style comment marker looks like an empty regular expression to Perl, which happily executes it, to no visible effect. Just as the here doc which is in void context.
The C version does not print any whitespace, the Perl version prints a newline after eachFizzBuzz.
//;say$_*2-1,Fizzbuzz for 1..500;<<'}';#include<stdio.h>main(){for(int i=1;i<1001;i++){i%3?printf("%d",i):printf("FizzBuzz");}}Try it online! (C)Try it online!
Try it online! (Perl)Try it online!
This hides the Perl code behind a C++ style comment, and the C code inside a Perl here doc, using the final character of the C code as the here doc terminator. The C++ style comment marker looks like an empty regular expression to Perl, which happily executes it, to no visible effect. Just as the here doc which is in void context.
The C version does not print any whitespace, the Perl version prints a newline after eachFizzBuzz.
The-Wno-implicit-int is only there to avoid TIO to emit warnings; compiling the code withgcc and no flags doesn't warn.
//;say$_*2-1,Fizzbuzz for 1..500;<<'}';#include<stdio.h>main(){for(int i=1;i<1001;i++){i%3?printf("%d",i):printf("FizzBuzz");}}Try it online! (C)
Try it online! (Perl)
This hides the Perl code behind a C++ style comment, and the C code inside a Perl here doc, using the final character of the C code as the here doc terminator. The C++ style comment marker looks like an empty regular expression to Perl, which happily executes it, to no visible effect. Just as the here doc which is in void context.
The C version does not print any whitespace, the Perl version prints a newline after eachFizzBuzz.
The-Wno-implicit-int is only there to avoid TIO to emit warnings; compiling the code withgcc and no flags doesn't warn.
//;say$_*2-1,Fizzbuzz for 1..500;<<'}';main(){for(int i=1;i<1001;i++){i%3?printf("%d",i):printf("FizzBuzz");}}This hides the Perl code behind a C++ style comment, and the C code inside a Perl here doc, using the final character of the C code as the here doc terminator. The C++ style comment marker looks like an empty regular expression to Perl, which happily executes it, to no visible effect. Just as the here doc which is in void context.
The C version does not print any whitespace, the Perl version prints a newline after eachFizzBuzz.
//;say$_*2-1,Fizzbuzz for 1..500;<<'}';#include<stdio.h>main(){for(int i=1;i<1001;i++){i%3?printf("%d",i):printf("FizzBuzz");}}Try it online! (C)
Try it online! (Perl)
This hides the Perl code behind a C++ style comment, and the C code inside a Perl here doc, using the final character of the C code as the here doc terminator. The C++ style comment marker looks like an empty regular expression to Perl, which happily executes it, to no visible effect. Just as the here doc which is in void context.
The C version does not print any whitespace, the Perl version prints a newline after eachFizzBuzz.
The-Wno-implicit-int is only there to avoid TIO to emit warnings; compiling the code withgcc and no flags doesn't warn.