I always love these things that are really scripts in two (or more) languages. Common is something like this on Windows to make a command script a Perl script. It lets you run your Perl script without having to make sure you had .pl extensions associated. Though, you needed Perl installed, so I never quite got the point.
@rem = '--*--Perl-*--
@echo off
echo Hello from a command script
perl -x -S %0 %*
goto endofperl
@rem ';
#!perl
print "Hello from Perl!\n";
__END__
:endofperl
By far very less common is to stuff some Perl code in a C# source file. A dev that was way too clever for his own code did this to have a Perl script that would update a C# script file and be self contained. This is a simple example of what it looked like, minus the instant headache anyone got that had to look at the real version:
#if PerlScript
$csharp=<<WhyJustWhy;
#endif
using System;
namespace Example
{
public static class Program
{
static void Main()
{
Console.WriteLine("Hello from C#");
}
}
}
#if PerlScript
WhyJustWhy
print("Hello from Perl!")
__END__
#endif
hawski|5 years ago
mmastrac|5 years ago
EDIT: hah, I should have realized that "//" is the C comment and "//usr/bin/tcc" is equivalent to "/usr/bin/tcc". Clever!
banana_giraffe|5 years ago
dfabulich|5 years ago
So it's running the file as a shell script, where the first line runs tcc on the current file and quits.
sergeykish|5 years ago
nialv7|5 years ago
shakna|5 years ago
keyle|5 years ago