[pve-devel] r5020 - pve-common/trunk

svn-commits at proxmox.com svn-commits at proxmox.com
Mon Aug 16 14:16:31 CEST 2010


Author: dietmar
Date: 2010-08-16 12:16:31 +0000 (Mon, 16 Aug 2010)
New Revision: 5020

Modified:
   pve-common/trunk/ChangeLog
   pve-common/trunk/Tools.pm
Log:
(trim): new trim() command


Modified: pve-common/trunk/ChangeLog
===================================================================
--- pve-common/trunk/ChangeLog	2010-08-16 12:09:01 UTC (rev 5019)
+++ pve-common/trunk/ChangeLog	2010-08-16 12:16:31 UTC (rev 5020)
@@ -4,6 +4,7 @@
 	do not need it.
 	(file_read_firstline): new function to read first line of file -
 	moved fron Storage.pm
+	(trim): new trim() command
 
 	* RESTHandler.pm (handle): remove ugly $resp parameter - we can
 	now use the new Expection object to return better error info.

Modified: pve-common/trunk/Tools.pm
===================================================================
--- pve-common/trunk/Tools.pm	2010-08-16 12:09:01 UTC (rev 5019)
+++ pve-common/trunk/Tools.pm	2010-08-16 12:16:31 UTC (rev 5020)
@@ -16,6 +16,7 @@
 file_read_firstline
 split_list
 safe_print
+trim
 );
 
 # flock: we use one file handle per process, so lock file
@@ -329,6 +330,17 @@
     return @data;
 }
 
+sub trim {
+    my $txt = shift;
+
+    return $txt if !defined($txt);
+
+    $txt =~ s/^\s+//;
+    $txt =~ s/\s+$//;
+    
+    return $txt;
+}
+
 sub safe_print {
     my ($filename, $fh, $data) = @_;
 




More information about the pve-devel mailing list