+Change 639 on 2001/09/05 by <gbarr@pobox.com> (Graham Barr)
+
+ Fix context type (caused a core on Tru64)
+ Call pp_rand via *(PL_ppaddr[OP_RAND])
+
+Change 638 on 2001/09/05 by <gbarr@pobox.com> (Graham Barr)
+
+ Documentation updates
+
+Change 637 on 2001/09/03 by <gbarr@pobox.com> (Graham Barr)
+
+ Release 1.03
+
Change 636 on 2001/09/03 by <gbarr@pobox.com> (Graham Barr)
More changes to help merging with core dist
SV *my_pad[2];
SV **old_curpad = PL_curpad;
+ /* We call pp_rand here so that Drand01 get initialized if rand()
+ or srand() has not already been called
+ */
my_pad[1] = sv_newmortal();
memzero((char*)(&dmy_op), sizeof(struct op));
dmy_op.op_targ = 1;
PL_op = &dmy_op;
PL_curpad = (SV **)&my_pad;
- /* Call *(PL_ppaddr[OP_RAND]) so that Drand01 get initialized if rand()
- or srand() has not already been called. Can't call pp_rand()
- since it's not in the public API (and shouldn't be).
- */
- *(PL_ppaddr[OP_RAND]);
+ *(PL_ppaddr[OP_RAND])();
PL_op = old_op;
PL_curpad = old_curpad;
for (index = items ; index > 1 ; ) {
# List::Util.pm
#
-# Copyright (c) 1997-2000 Graham Barr <gbarr@pobox.com>. All rights reserved.
+# Copyright (c) 1997-2001 Graham Barr <gbarr@pobox.com>. All rights reserved.
# This program is free software; you can redistribute it and/or
# modify it under the same terms as Perl itself.
our @ISA = qw(Exporter DynaLoader);
our @EXPORT_OK = qw(first min max minstr maxstr reduce sum shuffle);
-our $VERSION = "1.03_00";
+our $VERSION = "1.04_00";
bootstrap List::Util $VERSION;
=head1 SYNOPSIS
- use List::Util qw(first sum min max minstr maxstr reduce);
+ use List::Util qw(first max maxstr min minstr reduce shuffle sum);
=head1 DESCRIPTION
$foo = first { defined($_) } @list # first defined value in @list
$foo = first { $_ > $value } @list # first value in @list which
# is greater than $value
-
+
This function could be implemented using C<reduce> like this
$foo = reduce { defined($a) ? $a : wanted($b) ? $b : undef } undef, @list
Similar to C<max>, but treats all the entries in the list as strings
and returns the highest string as defined by the C<gt> operator.
If the list is empty then C<undef> is returned.
-
- $foo = maxstr 'A'..'Z' # 'Z'
+
+ $foo = maxstr 'A'..'Z' # 'Z'
$foo = maxstr "hello","world" # "world"
$foo = maxstr @bar, @baz # whatever
and returns the lowest string as defined by the C<lt> operator.
If the list is empty then C<undef> is returned.
- $foo = maxstr 'A'..'Z' # 'A'
- $foo = maxstr "hello","world" # "hello"
- $foo = maxstr @bar, @baz # whatever
+ $foo = minstr 'A'..'Z' # 'A'
+ $foo = minstr "hello","world" # "hello"
+ $foo = minstr @bar, @baz # whatever
This function could be implemented using C<reduce> like this
each time. The first call will be with C<$a> and C<$b> set to the first
two elements of the list, subsequent calls will be done by
setting C<$a> to the result of the previous call and C<$b> to the next
-element in the list.
+element in the list.
Returns the result of the last call to BLOCK. If LIST is empty then
C<undef> is returned. If LIST only contains one element then that
Returns the elements of LIST in a random order
+ @cards = shuffle 0..51 # 0..51 in a random order
+
=item sum LIST
Returns the sum of all the elements in LIST.
=head1 COPYRIGHT
-Copyright (c) 1997-2000 Graham Barr <gbarr@pobox.com>. All rights reserved.
+Copyright (c) 1997-2001 Graham Barr <gbarr@pobox.com>. All rights reserved.
This program is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.
# Scalar::Util.pm
#
-# Copyright (c) 1997-2000 Graham Barr <gbarr@pobox.com>. All rights reserved.
+# Copyright (c) 1997-2001 Graham Barr <gbarr@pobox.com>. All rights reserved.
# This program is free software; you can redistribute it and/or
# modify it under the same terms as Perl itself.
=head1 SYNOPSIS
- use Scalar::Util qw(blessed dualvar reftype weaken isweak);
+ use Scalar::Util qw(blessed dualvar isweak readonly reftype tainted weaken);
=head1 DESCRIPTION
If EXPR evaluates to a blessed reference the name of the package
that it is blessed into is returned. Otherwise C<undef> is returned.
+ $scalar = "foo";
+ $class = blessed $scalar; # undef
+
+ $ref = [];
+ $class = blessed $ref; # undef
+
+ $obj = bless [], "Foo";
+ $class = blessed $obj; # "Foo"
+
=item dualvar NUM, STRING
Returns a scalar that has the value NUM in a numeric context and the
value STRING in a string context.
$foo = dualvar 10, "Hello";
- $num = $foo + 2; # 12
- $str = $foo . " world"; # Hello world
+ $num = $foo + 2; # 12
+ $str = $foo . " world"; # Hello world
=item isweak EXPR
If EXPR is a scalar which is a weak reference the result is true.
+ $ref = \$foo;
+ $weak = isweak($ref); # false
+ weaken($ref);
+ $weak = isweak($ref); # true
+
=item readonly SCALAR
Returns true if SCALAR is readonly.
+ sub foo { readonly($_[0]) }
+
+ $readonly = foo($bar); # false
+ $readonly = foo(0); # true
+
=item reftype EXPR
If EXPR evaluates to a reference the type of the variable referenced
is returned. Otherwise C<undef> is returned.
+ $type = reftype "string"; # undef
+ $type = reftype \$var; # SCALAR
+ $type = reftype []; # ARRAY
+
+ $obj = bless {}, "Foo";
+ $type = reftype $obj; # HASH
+
=item tainted EXPR
Return true if the result of EXPR is tainted
+ $taint = tainted("constant"); # false
+ $taint = tainted($ENV{PWD}); # true if running under -T
+
=item weaken REF
REF will be turned into a weak reference. This means that it will not
This is useful for keeping copies of references , but you don't want to
prevent the object being DESTROY-ed at its usual time.
+ {
+ my $var;
+ $ref = \$var;
+ weaken($ref); # Make $ref a weak reference
+ }
+ # $ref is now undef
+
=back
=head1 COPYRIGHT
-Copyright (c) 1997-2000 Graham Barr <gbarr@pobox.com>. All rights reserved.
-This program is free software; you can redistribute it and/or modify it
+Copyright (c) 1997-2001 Graham Barr <gbarr@pobox.com>. All rights reserved.
+This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
-except weaken and isweak which are
+Except weaken and isweak which are
Copyright (c) 1999 Tuomas J. Lukka <lukka@iki.fi>. All rights reserved.
This program is free software; you can redistribute it and/or modify it