The Perl and Raku Conference 2025: Greenville, South Carolina - June 27-29 Learn more

NAME

String::Stomp - Removes empty leading and trailing lines

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

VERSION

Version 0.0103, released 2017-12-31.

SYNOPSIS

sub out {
print stomp q{
A short
text
};
}
# is exactly the same as
sub out {
print q{ A short
text};
}

DESCRIPTION

String::Stomp provides stomp, a simple function that removes all leading and trailing lines that only consist of white space or line breaks.

FUNCTIONS

stomp $string

# ' hello'
my $string = stomp q{
hello
};

MORE EXAMPLES

Usage with qs

Syntax::Feature::Qs adds qs and qqs that removes all leading whitespace from all lines in a string:

# these three packages are equivalent:
package Example::Stomp {
use syntax 'qs';
sub out {
print stomp qs{
This is
a multi line
string.
};
}
}
package Example::Q {
sub out {
print q{This is
a multi line
string.};
}
}
sub out {
(my $text = <<" END") =~ s{^ {12}}{}gm;
This is
a multi line
string.
END
$text =~ s{\v\z}{};
print $text;
}
}

SEE ALSO

SOURCE

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

HOMEPAGE

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

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.