Skip to content

Instantly share code, notes, and snippets.

@leejo
Last active August 29, 2015 13:58
Show Gist options
  • Save leejo/9971435 to your computer and use it in GitHub Desktop.
Save leejo/9971435 to your computer and use it in GitHub Desktop.
I have bigballofmud.pl that calls (requires) many littleballsofmud.pl,
none of which use strict and have many globals (there is no way i can
add use strict to any of these... yet). I want to add a new littleballofmud.pl,
but of course want to use strict. I still need to access the global
vars from bigballofmud.pl (and again, can't modify it to pass args)
but want littleballofmud.pl to be testable outside of bigballofmud.pl
under full strict *not* using globals.
My solution is this in littleballofmud.pl:
sub foo {
# if globals are defined use them, otherwise unpack args
our ( $first,$second,$third );
$first // do { ( $first,$second,$third ) = @_ };
}
This seems reasonable, but also potentially a WTF. Thoughts?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment