String::Trim(3pm)
π String::Trim β bestie, we're trimming whitespace π
okay so this is String::Trim, a User Contributed Perl Documentation page, and it's literally here to trim whitespace off your strings. that's it. that's the whole job. and she does it flawlessly. β¨
πΈ VERSION πΈ
version 0.005
β¨ SYNOPSIS β¨
no cap, here's the whole vibe:
use String::Trim;
print "Do it? ";
trim(my $response = <>);
print "'$response'\n";
likeβ¦ look at her. trim right there in the wild, doing the most with the least. π«Ά
π¦ DESCRIPTION π¦
String::Trim trims whitespace off your strings. and yeah, chomp exists, but chomp only trims $/ (which, typically, is your newline). trim said "not me being limited like that" and trims all leading and trailing whitespace. main character energy, fr fr. π
π FUNCTIONS π
π trim
returns the string with all leading and trailing whitespace removed. trimming undef gives you undef back β she's not gonna invent a string for you, that's not the vibe. alternatively, you can trim in-place. bestie's flexible like that πβοΈ
my $var = ' my string ';
my $trimmed = trim($var);
# OR
trim($var);
trim also knows how to trim an array or arrayref. she contains multitudes:
my @to_trim = (' one ', ' two ', ' three ');
my @trimmed = trim(@to_trim);
# OR
trim(@to_trim);
# OR
my $trimmed = trim(\@to_trim);
# OR
trim(\@to_trim);
π RATIONALE π
so why does this exist? because trim is often used by beginners, who may not understand how to spin their own. and that's fine!! we all start somewhere!! π₯Ί
the tea: while String::Util does have a trim function, it depends on Debug::ShowStuff, which depends on Taint, which fails the test suite, and doesn't appear to be maintained. π not the dependency chain of doom. meanwhile this module installs, is actively maintained, and has no non-core dependencies. we love a low-maintenance queen.
other options include Text::Trim and String::Strip (which is implemented in XS, and is therefore likely to be very fast, but requires a C compiler). so like, String::Strip is the fast one if you've got a C compiler lying around, and Text::Trim is also right there. options!! we love options!! πΈ
π AVAILABILITY π
the latest version of this module is available from the Comprehensive Perl Archive Network (CPAN). visit <http://www.perl.com/CPAN/> to find a CPAN site near you, or see <http://search.cpan.org/dist/String-Trim/>.
the development version lives at <http://github.com/doherty/String-Trim> and may be cloned from <git://github.com/doherty/String-Trim.git>. and instead of sending patches, please fork this project using the standard git and github infrastructure. fork it bestie, that's the move π
π§ SOURCE π§
the development version is on github at <http://github.com/doherty/String-Trim> and may be cloned from <git://github.com/doherty/String-Trim.git>
(yes she said it twice, she's thorough, periodt)
π BUGS AND LIMITATIONS π
no bugs have been reported. π iconic behaviour, honestly.
please report any bugs or feature requests through the web interface at <https://github.com/doherty/String-Trim/issues>.
if you do find a bug, don't suffer in silence β the issues page is right there, and the maintainers wanna know π
π CREDITS π
this module was inspired by code at <http://www.perlmonks.org/?node_id=36684> written by japhy (Jeff Pinyan), dragonchild, and Aristotle. this Perl module was written by Mike Doherty.
shoutout to the perlmonks thread that started it all, we owe her everything π«Ά
π AUTHORS π
- Mike Doherty <doherty@cpan.org>
- Jeff Pinyan <pinyan@cpan.org>
- Rob Kinyon <rkinyon@cpan.org>
- ΞΟΞΉΟΟΞΏΟα½³Ξ»Ξ·Ο Ξ Ξ±Ξ³ΞΊΞ±Ξ»ΟΞΆα½΅Ο (Aristotle Pagaltzis) <aristotle@cpan.org>
β COPYRIGHT AND LICENSE β
this software is copyright (c) 2010 by Mike Doherty.
this is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
and that's the whole page bestie π this was String::Trim(3pm), documented under perl v5.36.0, dated 2022-11-20. go forth and trim β¨π¦π
π¦ where this page comes from
- debian bookworm: libstring-trim-perl 0.005-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libstring-trim-perl 0.005-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libstring-trim-perl 0.005-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libstring-trim-perl 0.005-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libstring-trim-perl 0.005-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms