+Change 763 on 2003/02/04 by <gbarr@pobox.com> (Graham Barr)
+
+ Fix linking error for older perls
+
+Change 762 on 2003/02/04 by <gbarr@pobox.com> (Graham Barr)
+
+ Make lln tests and perl implementation mimic changes to looks_like_number
+ in different perl versions
+
+Change 761 on 2003/02/04 by <gbarr@pobox.com> (Graham Barr)
+
+ Add looks_like_number
+
+Change 760 on 2003/02/04 by <gbarr@pobox.com> (Graham Barr)
+
+ Ensure PERL_DL_NONLAZY is false so we don't catch link errors during
+ bootstrap and then test the perl only version
+
Change 759 on 2002/12/12 by <gbarr@pobox.com> (Graham Barr)
Release 1.09
Change 751 on 2002/10/18 by <gbarr@pobox.com> (Graham Barr)
Fix context so that sub for reduce/first is always in a scalar context
- Fix sum/min/max so that they dont upgrade thier argumetns to NVs
+ Fix sum/min/max so that they dont upgrade thier arguments to NVs
if they are IV or UV
Change 750 on 2002/10/14 by <gbarr@pobox.com> (Graham Barr)
#include <XSUB.h>
#ifndef PERL_VERSION
-# include <patchlevel.h>
-# ifndef PERL_VERSION
-# include <could_not_find_Perl_patchlevel.h>
-# endif
+# include "patchlevel.h"
# define PERL_REVISION 5
# define PERL_VERSION PATCHLEVEL
# define PERL_SUBVERSION SUBVERSION
# endif
#endif
-#ifndef PTR2IV
-# define PTR2IV(ptr) (IV)(ptr)
+#ifndef PTR2UV
+# define PTR2UV(ptr) (UV)(ptr)
#endif
MODULE=List::Util PACKAGE=List::Util
croak("vstrings are not implemented in this release of perl");
#endif
+int
+looks_like_number(sv)
+ SV *sv
+PROTOTYPE: $
+CODE:
+ RETVAL = looks_like_number(sv);
+OUTPUT:
+ RETVAL
+
BOOT:
{
our @ISA = qw(Exporter DynaLoader);
our @EXPORT_OK = qw(first min max minstr maxstr reduce sum shuffle);
-our $VERSION = "1.09_00";
+our $VERSION = "1.10_00";
our $XS_VERSION = $VERSION;
$VERSION = eval $VERSION;
require List::Util; # List::Util loads the XS
our @ISA = qw(Exporter);
-our @EXPORT_OK = qw(blessed dualvar reftype weaken isweak tainted readonly openhandle refaddr isvstring);
+our @EXPORT_OK = qw(blessed dualvar reftype weaken isweak tainted readonly openhandle refaddr isvstring looks_like_number);
our $VERSION = $List::Util::VERSION;
sub openhandle ($) {
=head1 SYNOPSIS
- use Scalar::Util qw(blessed dualvar isweak readonly refaddr reftype tainted weaken);
+ use Scalar::Util qw(blessed dualvar isweak readonly refaddr reftype tainted weaken isvstring looks_like_number);
=head1 DESCRIPTION
weaken($ref);
$weak = isweak($ref); # true
+=item looks_like_number EXPR
+
+Returns true if perl thinks EXPR is a number. See
+L<perlapi/looks_like_number>.
+
=item openhandle FH
Returns FH if FH may be used as a filehandle and is open, or FH is a tied
--- /dev/null
+#!/usr/bin/perl -w
+# -*- perl -*-
+
+
+#
+# $Id: $
+# Author: Slaven Rezic
+#
+
+use strict;
+use vars qw(%Config);
+
+BEGIN {
+ unless (-d 'blib') {
+ chdir 't' if -d 't';
+ @INC = '../lib';
+ require Config; import Config;
+ keys %Config; # Silence warning
+ if ($Config{extensions} !~ /\bList\/Util\b/) {
+ print "1..0 # Skip: List::Util was not built\n";
+ exit 0;
+ }
+ }
+}
+
+use Scalar::Util qw(looks_like_number);
+
+my $i;
+sub ok { print +(($_[0] eq $_[1]) ? "": "not "), "ok ",++$i,"\n" }
+
+print "1..12\n";
+
+ok(!!looks_like_number("1"), 1);
+ok(!!looks_like_number("-1"), 1);
+ok(!!looks_like_number("+1"), 1);
+ok(!!looks_like_number("1.0"), 1);
+ok(!!looks_like_number("+1.0"), 1);
+ok(!!looks_like_number("-1.0"), 1);
+ok(!!looks_like_number("-1.0e-12"), 1);
+ok(!!looks_like_number("Inf"), $] >= 5.006001);
+ok(!!looks_like_number("Infinity"), $] >= 5.008);
+ok(!!looks_like_number("NaN"), $] >= 5.008);
+ok(!!looks_like_number("foo"), '');
+ok(!!looks_like_number(undef), 1);
+# That's enough - we trust the perl core tests like t/base/num.t
+
+__END__