Hey::Common

Common functions used in other Hey::* modules
Download

Hey::Common Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Dusty Wilson
  • Publisher web site:
  • http://search.cpan.org/~wilsond/

Hey::Common Tags


Hey::Common Description

Common functions used in other Hey::* modules Hey::Common is a Perl module with common functions used in other Hey::* modules.SYNOPSIS use Hey::Common; my $common = Hey::Common->new; my $money = $common->formatMoney(524.4); # will return string "524.40"new my $common = Hey::Common->new;This function provides access to all of these following methods.forceArray $data->{users} = $common->forceArray($data->{users});The input can either be an array ref or non-array ref. The output will either be that same array ref, or the non-array ref as the only item in an array as a ref.This is useful for items that might or might not be an array ref, but you are expecting an array ref.randomCode $someRandomCode = $common->randomCode($lengthOfCodeRequested, $keyStringOfPermittedCharacters); $someRandomCode = $common->randomCode(); # defaults for length and key $someRandomCode = $common->randomCode(8); # choose a specific length, but default key $someRandomCode = $common->randomCode(12, 'abcdefg'); # choose a specific length and key$lengthOfCodeRequested defaults to 16.$keyStringOfPermittedCharacters defaults to 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'.deepCopy my $newCopyOfSomeHashRef = $common->deepCopy($someHashRef);It makes a copy of a reference instead of making a reference to it. There's some usefulness there.isAffirmative if ($common->isAffirmative('y')) { print "'y' is affirmative, so you'll see this."; } if ($common->isAffirmative('no')) { print "'no' is not affirmative, so you won't see this"; }This checks to see if the value is affirmative.Things that are affirmative are: 'y', 'yes', 't', 'true', or any true numerical value.isNegative if ($common->isNegative('y')) { print "'y' is not negative, so you won't see this."; } if ($common->isNegative('no')) { print "'no' is negative, so you'll see this"; }This checks to see if the value is negative.Things that are negative are: 'n', 'no', 'f', 'false', any false numerical value (zero), or undef/null.smtpClient my @aListOfRecipientEmailAddresses = ('george@somewhere.com', 'ed@server.com', 'ralph@elsewhere.com'); my $contentOfEmailIncludingHeader = 'smtp.server.someplace.com', From => 'fred@someplace.com', To => @aListOfRecipientEmailAddresses, Content => $contentOfEmailIncludingHeader });'Host' is optional and defaults to 'localhost'. Of course, you would need to be able to send email through whatever host you specify.'From' is a single email address that is used as the envelope address.'To' can be a single email address or a list of email addresses as a scalar or an array ref.'Content' is the content of the email, with header and body included.formatMoney my $money = 515.3; $money = $common->formatMoney($money);$money is the non-formatted money amount. It will be returned as a formatted string, but with no currency symbol.sha1 my $something = 'This is something that will be hashed.'; my $sha1Hash = $common->sha1($something);$something is any value that you want hashed. It can be a binary value or a simple scalar.$sha1Hash is a simple sha1 hex of whatever you passed in. Requirements: · Perl


Hey::Common Related Software