Array::Autojoin

Arrayrefs that stringify as join(", ", @$it)
Download

Array::Autojoin Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Sean M. Burke
  • Publisher web site:
  • http://search.cpan.org/~sburke/

Array::Autojoin Tags


Array::Autojoin Description

Arrayrefs that stringify as join(", ", @$it) Array::Autojoin is an extremely short and simple Perl module that provides one exported function, mkarray( ...items... ), which makes an arrayref (containing those items) belonging to a class that does nothing other than specifying to Perl that when you want the string value of that arrayref, instead of giving something like "ARRAY(0x171568f)", it returns a happy string consisting of join(', ', @$arrayref).Also, rather incidentally:* In boolean context (like print "Yow!" if $arrayref), the boolean value is true iff the reference is to an array containing at least one boolean-true value. So: mkarray() is boolean-false -- no values at all mkarray('','','','') is boolean-false -- no values are true mkarray('',0,undef ) is boolean-false -- no values are true mkarray('', 123 ) is boolean-true -- there's a true value (123) mkarray("PIE" ) is boolean-true -- there's a true value ("PIE")* In numeric scalar context -- where join(', ', @$arrayref) would be unhelpful -- you get the numeric value of the first item (or zero if there's no items): my $z = mkarray(3,7,19,63,30); print 39 + $z; # numeric $z yields 3, so this prints 42* ".=" is overloaded to append to the last element (or in the case of an empty array, to create a new element): my $headword = "biscocho"; my $gloss = mkarray("cookie", "biscuit"); $headword .= "!"; $gloss .= "!"; print "$headword\: $gloss\n"; # Prints "biscocho!: cookie, biscuit!\n" push @$gloss, "hooboy"; # see, can still treat it like a normal array ref printf "Count of glosses: %d\n", scalar(@$gloss); # Prints: Count of glosses: 3 print "Gloss bits: ", map("< $_ > ", @$gloss), "\n"; # Prints: Gloss bits: < cookie > < biscuit! > < hooboy >SYNOPSIS use Array::Autojoin; my $headword = "biscocho"; my $gloss = mkarray("cookie", "biscuit"); print "$headword\: $gloss.\n"; # Prints "biscocho: cookie, biscuit.\n"; Requirements: · Perl


Array::Autojoin Related Software