String::Trim(3pm)

πŸ“¦
version 0.005 Β· 4 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– 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>

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