Listify(3pm)
π 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 π
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
- ubuntu noble: libscalar-listify-perl 0.03-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libscalar-listify-perl 0.03-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libscalar-listify-perl 0.03-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