commit 72854192faddf3a039d7894ec6fb362cf5d62b6d parent ef4fda983a7d5739c10ba292bef6a3e79929eb91 Author: Andreas Guldstrand <andreas.guldstrand@gmail.com> Date: Sat, 9 Apr 2016 23:42:48 +0000 Add indent() sub for easy indenting of text Diffstat:
| M | SBO-Lib/lib/SBO/Lib.pm | | | 12 | ++++++++++++ |
1 file changed, 12 insertions(+), 0 deletions(-)
diff --git 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;