diff options
author | Andreas Guldstrand <andreas.guldstrand@gmail.com> | 2016-04-09 23:42:48 +0000 |
---|---|---|
committer | Andreas Guldstrand <andreas.guldstrand@gmail.com> | 2016-04-09 23:42:48 +0000 |
commit | 72854192faddf3a039d7894ec6fb362cf5d62b6d (patch) | |
tree | 18a70f5aac18bc79a46454db782749211044a7e5 /SBO-Lib | |
parent | ef4fda983a7d5739c10ba292bef6a3e79929eb91 (diff) | |
download | sbotools2-72854192faddf3a039d7894ec6fb362cf5d62b6d.tar.xz |
Add indent() sub for easy indenting of text
Diffstat (limited to 'SBO-Lib')
-rw-r--r-- | SBO-Lib/lib/SBO/Lib.pm | 12 |
1 files changed, 12 insertions, 0 deletions
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; |