From 6af4f0693afb733ba3c092eb8cd3417c1da6f5bb Mon Sep 17 00:00:00 2001 From: Robert Anderson <randerson@lbsd.net> Date: Tue, 3 Mar 2009 10:59:06 +0000 Subject: [PATCH] * Added niceUndef function to print undefined strings nicely --- smradius/util.pm | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/smradius/util.pm b/smradius/util.pm index 4512b332..9557044f 100644 --- a/smradius/util.pm +++ b/smradius/util.pm @@ -28,11 +28,27 @@ require Exporter; our (@ISA,@EXPORT); @ISA = qw(Exporter); @EXPORT = qw( + niceUndef templateReplace ); +## @fn niceUndef($string) +# If string defined return 'string', or if undefined return -undef- +# +# @param string String to check +# +# @return Return 'string' if defined, or -undef- otherwise +sub niceUndef +{ + my $string = shift; + + + return defined($string) ? "'$string'" : '-undef-'; +} + + ## @fn templateReplace($string,$hashref) # Template string replacer function # -- GitLab