use strict; # Transform 'local' to 'my', and get rid of needless # initialization to 'undef' my $usefuldata = 1; # in real life, lots of logic here if ( blah_blah() ) { # Eliminated second definition of $usefuldata $usefuldata = 2; # in real life, lots of logic here } insert_into_database($usefuldata)