use strict; #use warnings; sub tt { my ($cookies, $param) = @_; my $str = '(' . (defined $cookies ? $cookies : 'undef'); $str .= ', ' . (defined $param ? $param : 'undef') . "):\t"; $str .= $cookies ? ( $param ? $param : '$cookies{"rows"}->value' ) : ( $param and $param =~ /^\d{1,2}$/ ? 'param( "rows" )' : 5); return $str; } print tt(undef, undef), "\n"; print tt(0, undef), "\n"; print tt(1, undef), "\n"; print tt("0but", undef), "\n"; print tt(undef, 0), "\n"; print tt(undef, 1), "\n"; print tt(undef, 11), "\n"; print tt(undef, 111), "\n"; print tt(undef, "0but"), "\n"; print tt(0, 0), "\n"; print tt(1, 1), "\n"; #### (undef, undef): (0, undef): (1, undef): $cookies{"rows"}->value (0but, undef): $cookies{"rows"}->value (undef, 0): 0 (undef, 1): param( "rows" ) (undef, 11): param( "rows" ) (undef, 111): 5 (undef, 0but): 5 (0, 0): 0 (1, 1): 1