[Gllug] Perl 'running' python and bash

Robert Newson ran at bullet3.fsnet.co.uk
Sun May 1 16:30:09 UTC 2005


Mark Hill wrote:

> Hi,
> 
> I've accidentally found that perl will 'run' python, bash and possibly
> other scripts. Through a bit of investigation, it seems that perl will
> look at the shebang line of a given script and call the appropriate
> interpretter. E.G: A python script consisting of:
> 
> #!/usr/bin/python
> print "Hello"
> 
> Can be executed as perl file.py

Normally extensions are of no importance to a *nix system: they're normally 
only for the benefit of (human) users.


> Is there any reason why perl does this, or was it implemented just for
> fun? 

No idea, but one possibility that springs to my mind is that it's using the 
same file execution mechanism/library as a shell - the one which looks at 
the "#!" magic number and so calls the relevant interpreter.

-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list