VMX::Common::callif()

databind
vitalif 2008-11-01 00:07:44 +00:00 committed by Vitaliy Filippov
parent f6d5cb24b5
commit 90b739e4b7
1 changed files with 16 additions and 1 deletions

View File

@ -16,7 +16,7 @@ require Exporter;
our @EXPORT_OK = qw(
quotequote min max trim htmlspecialchars strip_tags strip_unsafe_tags
file_get_contents dbi_hacks ar1el filemd5 mysql_quote updaterow_hashref
insertall_hashref deleteall_hashref dumper_no_lf str2time
insertall_hashref deleteall_hashref dumper_no_lf str2time callif
);
our %EXPORT_TAGS = (all => [ @EXPORT_OK ]);
@ -378,5 +378,20 @@ sub str2time
return Date::Parse::str2time($str);
}
# если значение - вернуть значение, если coderef - вызвать и вернуть значение
sub callif
{
my $sub = shift;
if (ref($sub) eq 'CODE')
{
return &$sub(@_);
}
elsif ($sub)
{
return $sub;
}
return wantarray ? () : undef;
}
1;
__END__