Myco::Util::Misc - a humble perl package


Myco documentation Contained in the Myco distribution.

Index


Code Index:

NAME

Top

Myco::Util::Misc - a humble perl package

SYNOPSIS

Top

  use Myco::Util::Misc;

DESCRIPTION

Top

A simple shell to store oft-used routines for miscellaneous tasks.

ADDED CLASS METHODS

Top

hash_with_no_values_to_array

  my $attribute_label = Myco::Util::Misc->pretty_print('person_last_name');
  my $do_these_words_match = $attribute_label eq 'Person Last Name';

Convert the keys of a hash ref with all values blank to an array ref. Mainly used to provide a hack to Config::General, which lacks a function to specify a multi-valued config value without many repetitious lines.

LICENSE AND COPYRIGHT

Top

SEE ALSO

Top

Myco (Myco),


Myco documentation Contained in the Myco distribution.
package Myco::Util::Misc;

###############################################################################
# $Id: Misc.pm,v 1.1 2006/03/17 20:59:08 sommerb Exp $
#
# See license and copyright near the end of this file.
###############################################################################

##############################################################################
# Dependencies
##############################################################################
# Module Dependencies and Compiler Pragma
use warnings;
use strict;

##############################################################################
# Programatic Dependencies

##############################################################################
# Constants
##############################################################################

##############################################################################
# Methods
##############################################################################

sub hash_with_no_values_to_array {
    my $self = shift;
    my $hash = shift;
    
    if (ref $hash eq 'HASH') {
        my @values = values %$hash;
        return [ keys %$hash ] unless grep /\w+/, @values;
    } else {
        return $hash;
    }
    
}

1;
__END__