in reply to default value for a scalar

like already posted by pc88mxer you can set default values with the || operator which has the drawback that it not only triggers the default value when the variable is unset, i.e. undef, but also for all other boolean false values like: 0, "" and "0". Because your default value is 0 this doesn't matter because all of this values would be converted to 0 anyway, but a warning would be raised.

E.g. when the the function would be called as print_if(0) the given 0 would be overwritten by your default 0, which no consequences of course.
If your default value would be now 1 the call print_if(0) would be changed to print_if(1). To avoid this use:

$odVal = defined $odVal ? $odVal : 0; $osVal = defined $osVal ? $osVal : 0;
In Perl 5.10 there is now the // operator which does exactly this, so you could write it so:
$odVal //= 0; $osVal //= 0;
Then, of course, your code wouldn't run with Perl <5.10, so don't use this just now.

You also could change the code posted by jwkrahn from

my ( $FH, $orderKey, $odVal, $osVal ) = map $_ || 0, @_[ 0 .. 3 ];
to
my ( $FH, $orderKey, $odVal, $osVal ) = map defined $_ ? $_ : 0, @_[ 0 + .. 3 ];
Finally if you just like to remove the warning you could put a no warnings 'uninitialized'; in your function. Then undef values would be taken as 0 without a warning.