分类: IT业界
2011-09-07 21:47:45
#include <stdio.h>
int x= 5;
int f(){
return x;
}
int g(){
int x = 1;
return f();
}
int main(int argc,char*argv[]){
printf("%d ",g());
}
#!/usr/bin/perl
sub f {
my $x = 'f'; # lexical
local $y = 'f'; # dynamic
$z = 'f'; # global
g();
print "in f after g: x=$x, y=$y, z=$z ";
}
sub g {
($x,$y,$z) = ('g','g','g');
}
($x,$y,$z) = ('top','top','top');
f();
print "at top after f: x=$x, y=$y, z=$z ";