From 72854192faddf3a039d7894ec6fb362cf5d62b6d Mon Sep 17 00:00:00 2001 From: Andreas Guldstrand Date: Sat, 9 Apr 2016 23:42:48 +0000 Subject: Add indent() sub for easy indenting of text --- SBO-Lib/lib/SBO/Lib.pm | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'SBO-Lib/lib/SBO/Lib.pm') diff --git a/SBO-Lib/lib/SBO/Lib.pm b/SBO-Lib/lib/SBO/Lib.pm index 818d8b8..46ef2f6 100644 --- a/SBO-Lib/lib/SBO/Lib.pm +++ b/SBO-Lib/lib/SBO/Lib.pm @@ -241,6 +241,18 @@ sub idx { return undef; } +sub indent { + my ($indent, $text) = @_; + return $text unless $indent; + + my @lines = split /\n/, $text; + foreach my $line (@lines) { + next unless length($line); + $line = (" " x $indent) . $line; + } + return join "\n", @lines; +} + # Move everything in /usr/sbo except distfiles and repo dirs into repo dir sub migrate_repo { make_path($repo_path) unless -d $repo_path; -- cgit v1.2.3