in reply to Re: Why no stay shared warning?
in thread Why no stay shared warning?

Note, a BEGIN block isn't necessary -- a bare block is fine as long as it is defined prior to the sub calls. Also, a BEGIN block may not always be the appropriate mechanism:

#!/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();

Now, if you comment out the BEGIN line above it will work as one might have expected. Not that I think this might be a common problem, but I thought it might be worthwhile to highlight the difference.