Subject: | Make functions exportable. |
The supplied patch makes module functions exportable as described by documentation.
Subject: | Text.pm.patch |
--- Text.pm 2014-12-16 16:50:49.341400000 +0200
+++ Text.pm_v1.1 2014-12-18 16:03:43.749761000 +0200
@@ -2,15 +2,22 @@
use strict;
+use Exporter 'import';
+our @EXPORT_OK = qw(pretyArray pretyHash);
+
use vars qw($VERSION);
-$VERSION = 1.0;
+$VERSION = 1.1;
sub pretyArray {
my $thingy = shift;
my $array;
my $text;
+ if (defined $thingy) {
+ unshift(@_, $thingy) unless ($thingy eq "MRP::Text");
+ }
+
if(@_==1 && "$_[0]" =~ /ARRAY/) {
$array = shift;
} else {
@@ -23,11 +30,16 @@
sub pretyHash {
my $thingy = shift;
- my $leader = shift;
my $hash;
my $text = "";
my ($key,$val);
+ if (defined $thingy) {
+ unshift(@_, $thingy) unless ($thingy eq "MRP::Text");
+ }
+
+ my $leader = shift;
+
if(@_==1 && (ref $_[0] eq 'HASH' or "$_[0]" =~/HASH/)) {
$hash = shift;
} else {
@@ -52,12 +64,17 @@
=head1 DESCRIPTION
Provides a small number of text manipulating methods that I use all
-the time. They are invoked as MRP::Text->func.
+the time. They are invoked as MRP::Text->func or simply as func if imported.
=head1 SYNOPSIS
print "got ", MRP::Text->pretyArray(@someList), "\n";
+or
+
+use MRP::Text 'pretyArray';
+print "got ", pretyArray(@someList), "\n";
+
=head1 Functions
=over