From Code to Community: Sponsoring The Perl and Raku Conference 2025 Learn more

NAME

String::Cushion - Vertically pad a string

Requires Perl 5.10.1+ Travis status Distribution kwalitee CPAN Testers result coverage 89.2%

VERSION

Version 1.0000, released 2020-04-30.

SYNOPSIS

sub out {
print cushion 2, 3, q{
A short
text
};
}
# is exactly the same as
sub out {
print q{
A short
text.
};
}

DESCRIPTION

String::Cushion provides cushion, a simple function that removes all leading and trailing lines and lines only consisting of white space or line breaks, and then adds a specified number of leading and trailing new lines (\n).

METHODS

cushion $number_of_new_lines, $string

# "\n hello\n"
my $string = cushion 1, q{
hello
};

cushion $number_of_leading_new_lines, $number_of_trailing_new_lines, $string

# "\n hello\n\n"
my $string = cushion 1, 2, q{
hello
};

SEE ALSO

SOURCE

https://github.com/Csson/p5-String-Cushion

HOMEPAGE

https://metacpan.org/release/String-Cushion

AUTHOR

Erik Carlsson <info@code301.com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2016 by Erik Carlsson.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.