note
pobocks
<p>__FILE__ is the file name that the __FILE__ token is in, and $0 is a variable containing the name of the program, as given to the shell.</p>
<p>They can most certainly be different - one case that comes to mind is a __FILE__ token in a library called by your program, but there are many others, particularly since you can assign to $0 (with varying effects on different OS), but you can't meaningfully assign to __FILE__.</p>
<p>Example code:</p>
<p><b>File 1 - firstfile</b></p>
<code>
#!/usr/bin/perl -w
use strict;
print $0 . "\n";
print __FILE__ . "\n";
do 'filetwo';
</code>
<p><b>File 2 - filetwo</b></p>
<code>
#!/usr/bin/perl -w
use strict;
print $0 . "\n";
print __FILE__ . "\n";
</code>
<p>It's simplistic, but should show the basic concept.</p>
<!-- Node text goes above. Div tags should contain sig only -->
<div class="pmsig"><div class="pmsig-572803">
<code>for(split(" ","tsuJ rehtonA lreP rekcaH")){print reverse . " "}print "\b.\n";</code>
</div></div>
995692
995692