Scalar-Listify-0.03/000755 000765 000024 00000000000 12275132546 014524 5ustar00adminstaff000000 000000 Scalar-Listify-0.03/Changes000644 000765 000024 00000000250 07207042177 016013 0ustar00adminstaff000000 000000 Revision history for Perl extension Scalar::Listify. 0.01 Wed Nov 22 14:11:11 2000 - original version; created by h2xs 1.20 with options -A -X -n Scalar::Listify Scalar-Listify-0.03/Listify.pm000644 000765 000024 00000004557 12275132520 016510 0ustar00adminstaff000000 000000 package Scalar::Listify; require 5.005_62; use strict; use warnings; require Exporter; our @ISA = qw(Exporter); # Items to export into callers namespace by default. Note: do not export # names by default without a very good reason. Use EXPORT_OK instead. # Do not simply export all your public functions/methods/constants. # This allows declaration use Scalar::Listify ':all'; # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK # will save memory. our @EXPORT; @EXPORT = qw(&listify &listify_aref); our $VERSION = '0.03'; # Preloaded methods go here. my $sub = 'Scalar::Listify::listify'; sub listify { scalar @_ == 1 or die "$sub only takes one argument and this argument must be a simple scalar or array reference"; my $scalar = shift; if (not ref($scalar)) { my @ret = ($scalar); return (@ret); } ref($scalar) eq 'ARRAY' and return @$scalar; require Data::Dumper; my $err = "Scalar::Listify::listify error - this function only takes simple scalars or references to arrays. I'm not sure what you gave me, but here is what Data::Dumper has to say about it:"; warn $err; warn Data::Dumper->Dump([$scalar],['bad_data']); } sub listify_aref { [ listify @_ ] } 1; __END__ =head1 NAME Scalar::Listify - produces an array(ref)? from a scalar value or array ref. =head1 SYNOPSIS 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 =head1 DESCRIPTION A lot of Perl code ends up with scalars having either a single scalar value or a reference to an array of scalar values. In order to handle the two conditions, one must check for what is in the scalar value before getting on with one's task. Ie: $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! =head2 EXPORT listify() - listify takes a scalar as an argument and returns the value of the scalar in a format useable in list contexts. listify_aref() - returns [ listify (@_) ] =head1 AUTHOR T. M. Brannon, =head1 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. =head1 SEE ALSO perl(1). =cut Scalar-Listify-0.03/Makefile.PL000644 000765 000024 00000000446 07207042177 016501 0ustar00adminstaff000000 000000 use ExtUtils::MakeMaker; # See lib/ExtUtils/MakeMaker.pm for details of how to influence # the contents of the Makefile that is written. WriteMakefile( 'NAME' => 'Scalar::Listify', 'VERSION_FROM' => 'Listify.pm', # finds $VERSION 'PREREQ_PM' => {}, # e.g., Module::Name => 1.1 ); Scalar-Listify-0.03/MANIFEST000644 000765 000024 00000000322 12275132546 015652 0ustar00adminstaff000000 000000 Changes Listify.pm MANIFEST Makefile.PL test.pl META.yml Module meta-data (added by MakeMaker) META.json Module JSON meta-data (added by MakeMaker) Scalar-Listify-0.03/META.json000644 000765 000024 00000001432 12275132546 016145 0ustar00adminstaff000000 000000 { "abstract" : "unknown", "author" : [ "unknown" ], "dynamic_config" : 1, "generated_by" : "ExtUtils::MakeMaker version 6.6302, CPAN::Meta::Converter version 2.120921", "license" : [ "unknown" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "Scalar-Listify", "no_index" : { "directory" : [ "t", "inc" ] }, "prereqs" : { "build" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "runtime" : { "requires" : {} } }, "release_status" : "stable", "version" : "0.03" } Scalar-Listify-0.03/META.yml000644 000765 000024 00000000660 12275132545 015776 0ustar00adminstaff000000 000000 --- abstract: unknown author: - unknown build_requires: ExtUtils::MakeMaker: 0 configure_requires: ExtUtils::MakeMaker: 0 dynamic_config: 1 generated_by: 'ExtUtils::MakeMaker version 6.6302, CPAN::Meta::Converter version 2.120921' license: unknown meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: Scalar-Listify no_index: directory: - t - inc requires: {} version: 0.03 Scalar-Listify-0.03/test.pl000644 000765 000024 00000001465 07747776446 016073 0ustar00adminstaff000000 000000 # Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl test.pl' ######################### We start with some black magic to print on failure. # Change 1..1 below to 1..last_test_to_print . # (It may become useful if the test is moved to ./t subdirectory.) BEGIN { $| = 1; print "1..1\n"; } END {print "not ok 1\n" unless $loaded;} use Scalar::Listify; $loaded = 1; print "ok 1\n"; ######################### End of black magic. # Insert your test code below (better if it prints "ok 13" # (correspondingly "not ok 13") depending on the success of chunk 13 # of the test code): my $scalar = 'ho there'; my $aref = [qw(a ref array ref got to go)]; use Data::Dumper; warn Dumper(listify_aref($scalar)); warn Dumper(listify_aref($aref));