Listify(3pm)

πŸ“¦
version 0.03 Β· 3 versions
, in ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’… NAME πŸ’…

Scalar::Listify β€” bestie, it produces an array (or array ref?? πŸ‘€) from a scalar value or an array ref. That's the whole vibe. Periodt.


✨ SYNOPSIS ✨

okay so picture this:

use Scalar::Listify;

$text_scalar = 'text';
$aref_scalar = [ 1.. 5 ];

print join ':', listify $text_scalar; # => text
print join ':', listify $aref_scalar; # => 1:2:3:4:5

like… it just works?? the scalar case gives you text, the arrayref case gives you 1:2:3:4:5. no drama, no chaos, just slay. πŸ¦‹


🌸 DESCRIPTION 🌸

so here's the situation that literally every Perl dev has lived through at least once: your code ends up holding a scalar that's either one single scalar value or a reference to an array full of scalar values. and you're just standing there like 🧍 because now you have to figure out which one you're holding before you can actually do the thing you wanted to do. it's giving side quest.

the classic move looks like this:

$text_scalar = 'text';
$aref_scalar = [ 1.. 5 ];

print ref($text_scalar) ? (join ':', @$text_scalar) : $text_scalar;

and this module is designed to address just that! no cap. that's the entire assignment and it ate. πŸ‘‘

πŸŽ€ EXPORT πŸŽ€

  • listify() β€” listify takes a scalar as an argument and hands you back the value of that scalar in a format you can actually use in list contexts. iconic behavior honestly.
  • listify_aref() β€” returns [ listify (@_) ]. cute, right? it's the arrayref glow-up. πŸ’–

πŸ‘‘ AUTHOR πŸ‘‘

T. M. Brannon, <tbone@CPAN.org>

like we have to stan. 🫢


Copyright 1999-present by Terrence Brannon.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

fr fr, free software, do your thing, just keep the same terms as Perl. πŸ’œ


πŸ”₯ SEE ALSO πŸ”₯

  • perl(1). that's it bestie, that's the whole list. iykyk.

and that's the whole page!! this one's from perl v5.36.0, dated 2022-10-13, brought to you by User Contributed Perl Documentation β€” ty for coming to my ted talk, mwah πŸŽ€βœ¨πŸ’…

πŸ“¦ where this page comes from