+=head2 english_join
+
+ print english_join(', ',' and ',@list);
+
+Joins list properly to make an english phrase.
+
+
+
+=cut
+
+sub english_join {
+ my ($normal,$last,@list) = @_;
+ if (@list <= 1) {
+ return @list?$list[0]:'';
+ }
+ my $ret = $last . pop(@list);
+ $ret = join($normal,@list) . $ret;
+ return $ret;
+}
+
+
+=head2 globify_scalar
+
+ my $handle = globify_scalar(\$foo);
+
+if $foo isn't already a glob or a globref, turn it into one using
+IO::Scalar. Gives a new handle to /dev/null if $foo isn't defined.
+
+Will carp if given a scalar which isn't a scalarref or a glob (or
+globref), and return /dev/null. May return undef if IO::Scalar or
+IO::File fails. (Check $!)
+
+=cut
+
+sub globify_scalar {
+ my ($scalar) = @_;
+ my $handle;
+ if (defined $scalar) {
+ if (defined ref($scalar)) {
+ if (ref($scalar) eq 'SCALAR' and
+ not UNIVERSAL::isa($scalar,'GLOB')) {
+ return IO::Scalar->new($scalar);
+ }
+ else {
+ return $scalar;
+ }
+ }
+ elsif (UNIVERSAL::isa(\$scalar,'GLOB')) {
+ return $scalar;
+ }
+ else {
+ carp "Given a non-scalar reference, non-glob to globify_scalar; returning /dev/null handle";
+ }
+ }
+ return IO::File->new('/dev/null','w');
+}
+