#!/usr/bin/perl -w use strict; use Getopt::Std; my %opt; getopt('n',\%opt); BEGIN { my $foo = $opt{n}; sub up { $foo++; sub get {$foo} } } up(); up(); print get();