Catman...x::trim(3pm)

πŸ“¦
version 1.2025 Β· 4 versions
, in ubuntu resolute, ubuntu stonking

πŸ’– NAME πŸ’–

Catmandu::Fix::trim β€” okay bestie, this one is literally just a little glow-up for your field values: it trims the leading and ending junk off them. That's it. That's the whole gig. ✨


✨ SYNOPSIS ✨

Lowkey the easiest syntax ever, no cap. Watch:

# the default mode trims whitespace
# e.g. foo => '   abc   ';

trim(foo) # foo => 'abc';
trim(foo, whitespace) # foo => 'abc';

# trim non-word characters
# e.g. foo => '   abc  / : .';
trim(foo, nonword) # foo => 'abc';

# trim accents
# e.g. foo => 'franΓ§ais' ;
trim(foo,diacritics) # foo => 'francais'

So like, mode one β€” the default β€” is giving "whitespace" and it trims whitespace off both ends. trim(foo) and trim(foo, whitespace) do the exact same thing, she's flexible like that. πŸ’…

Mode two is nonword, and she eats all the non-word characters hanging around the edges β€” slashes, colons, dots, all of it. The way that ' abc / : .' becomes 'abc'?? Iconic behaviour. πŸŽ€

Mode three is diacritics, and she strips the accents so 'franΓ§ais' turns into 'francais'. Normalising your Unicode like a main character. πŸ¦‹


🌸 SEE ALSO 🌸

  • Catmandu::Fix β€” the mothership, go say hi 🫢

πŸ’€ fr fr, that's the entire page, I'm not even joking. Short king behaviour but she does her job.

Mwah, mwah, mwah β€” this lil' cutie is documented by the User Contributed Perl Documentation girlies, running on perl v5.40.1, last touched 2026-01-24. Slay, bestie, go trim something. πŸ’–βœ¨πŸŒ·

πŸ“¦ where this page comes from