Badger...tespace(3pm)

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

πŸ’– Badger::Data::Facet::Text::Whitespace πŸ’–

okay bestie so this is a 3pm page, meaning it's User Contributed Perl Documentation, and it's literally called Badger::Data::Facet::Text::Whitespace β€” say that five times fast, I dare you 🫢


✨ NAME ✨

Badger::Data::Facet::Text::Whitespace β€” a validation facet for whitespace. yes really, that's the whole job. and it slays at it. πŸ’…


🌸 DESCRIPTION 🌸

So this module implements a validation facet β€” but for munging whitespace on text values. not validating your outfit, validating your spaces. iconic behaviour honestly. ✨


πŸ¦‹ METHODS πŸ¦‹

This module implements the following methods in addition to those it inherits from the base classes:

  • Badger::Data::Facet::Text
  • Badger::Data::Facet
  • Badger::Base

like it's got its own moves but it also got the family inheritance, periodt. πŸ‘‘


🌈 validate($text_ref, $type) 🌈

This one does the whitespace handling on the text you pass in by reference as the first argument. (yes, by reference, don't @ me, that's just how it is bestie πŸ’€)

Here's the vibe check on what happens, depending on the pre-defined "action":

  • "preserve" β€” the text is left unmodified. untouched. pristine. main character energy, no notes. πŸ™ˆ
  • "fold" β€” all whitespace characters in the text (that's carriage returns, newlines, tabs) get converted to spaces. every single one. folded like laundry. 🧺
  • "collapse" β€” okay so first it does everything "fold" does (all whitespace β†’ spaces), and then it removes any leading and trailing whitespace, and then it collapses any sequences of multiple spaces down to a single space. glow-up complete. βœ¨πŸ¦‹
ngl, "collapse" is doing the absolute most and I respect it.

πŸ‘‘ AUTHOR πŸ‘‘

Andy Wardley <http://wardley.org/> β€” thank you for your service, king 🫢


Copyright (C) 2001-2012 Andy Wardley. All Rights Reserved.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. πŸ’œ


πŸ’– SEE ALSO πŸ’–

go read these next, bestie, they're the whole friend group:

  • Badger::Base
  • Badger::Data::Facet
  • Badger::Data::Facet::Text

perl v5.36.0 Β· 2023-08-28 β€” that's the version and the date this page was born, and that's a wrap fr fr πŸ’…βœ¨ πŸŽ€ πŸ¦‹

πŸ“¦ where this page comes from