use strict; use warnings; sub ttw { my( $cookie, $param ) = @_; my $str = '(' . (defined $cookie ? $cookie : 'undef'); $str .= ',' . (defined $param ? $param : 'undef') . "):\t"; $str .= $cookie ||= $param && $param =~ /^\w{1,6}$/ ? $param : 'default'; $str .= "\n"; return $str; } sub ttd { my( $cookie, $param ) = @_; my $str = '(' . (defined $cookie ? $cookie : 'undef'); $str .= ',' . (defined $param ? $param : 'undef') . "):\t"; $str .= $cookie ||= $param && $param =~ /^\d{1,2}$/ ? $param : 5; $str .= "\n"; return $str; } print ttw( 'yellow', 'blue' ); print ttw( 'green', undef ); print ttw( undef, 'teal' ); print ttw( undef, 'chartreuse' ); print ttw( undef, undef ); print ttd( undef, undef ); print ttd( 4, undef); print ttd( 444, undef); print ttd( undef, 3); print ttd( undef, 333); print ttd( 6, 7);