In my opinion the answer to your question is 'yes'. At least that's what I'd do. I'd probably just pass 0 through... In the sub I would then check for the value before proceeding.
From program A:
build_url( $account ,$transaction, $location, $fname, $lname);
From program B:
build_url( $account, 0, 0, $fname, $lname);
From program C:
build_url( $account, $transaction, 0, $fname, $lname);
From program D:
build_url( $account ,$transaction, $location, $fname, $lname);
sub build_url
{
my ($account ,$transaction, $location, $fname, $lname) = @_;
if ($location) { ... do what you would do ... }#example
}