#!/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 ";
程序的输出结果: in f after g: x=f, y=g, z=g at top after f: x=g, y=top, z=g