| 1 | #line 1 |
| 2 | # Scalar::Util.pm |
| 3 | # |
| 4 | # Copyright (c) 1997-2007 Graham Barr <[email protected]>. All rights reserved. |
| 5 | # This program is free software; you can redistribute it and/or |
| 6 | # modify it under the same terms as Perl itself. |
| 7 | |
| 8 | package Scalar::Utilscip-perl cpan Icon-FamFamFam-Silk 0.002001003 Scalar/Util/; |
| 9 | |
| 10 | use strictscip-perl cpan Icon-FamFamFam-Silk 0.002001003 strict/; |
| 11 | use varsscip-perl cpan Icon-FamFamFam-Silk 0.002001003 vars/ qw(@ISA @EXPORT_OK $VERSION @EXPORT_FAIL); |
| 12 | requirescip-perl cpan Icon-FamFamFam-Silk 0.002001003 Scalar/Util/require(). Exporter; |
| 13 | requirescip-perl cpan Icon-FamFamFam-Silk 0.002001003 Scalar/Util/require(). List::Util; # List::Util loads the XS |
| 14 | |
| 15 | @ISAscip-perl cpan Icon-FamFamFam-Silk 0.002001003 Scalar/Util/`@ISA`. = qw(Exporter); |
| 16 | @EXPORT_OKscip-perl cpan Icon-FamFamFam-Silk 0.002001003 Scalar/Util/`@EXPORT_OK`. = qw(blessed dualvar reftype weaken isweak tainted readonly openhandle refaddr isvstring looks_like_number set_prototype); |
| 17 | $VERSIONscip-perl cpan Icon-FamFamFam-Silk 0.002001003 Scalar/Util/$VERSION. = "1.21"; |
| 18 | $VERSIONscip-perl cpan Icon-FamFamFam-Silk 0.002001003 Scalar/Util/$VERSION. = eval $VERSIONscip-perl cpan Icon-FamFamFam-Silk 0.002001003 Scalar/Util/$VERSION.; |
| 19 | |
| 20 | unless (definedscip-perl cpan Icon-FamFamFam-Silk 0.002001003 Scalar/Util/defined(). &dualvarscip-perl cpan Icon-FamFamFam-Silk 0.002001003 Scalar/Util/dualvar().) { |
| 21 | # Load Pure Perl version if XS not loaded |
| 22 | requirescip-perl cpan Icon-FamFamFam-Silk 0.002001003 Scalar/Util/require(). Scalar::Util::PP; |
| 23 | Scalar::Util::PP->importscip-perl cpan Icon-FamFamFam-Silk 0.002001003 Scalar/Util/PP/import().; |
| 24 | pushscip-perl cpan Icon-FamFamFam-Silk 0.002001003 Scalar/Util/push(). @EXPORT_FAILscip-perl cpan Icon-FamFamFam-Silk 0.002001003 Scalar/Util/`@EXPORT_FAIL`., qw(weaken isweak dualvar isvstring set_prototype); |
| 25 | } |
| 26 | |
| 27 | sub export_failscip-perl cpan Icon-FamFamFam-Silk 0.002001003 Scalar/Util/export_fail(). { |
| 28 | if (grepscip-perl cpan Icon-FamFamFam-Silk 0.002001003 Scalar/Util/grep(). { /dualvar/ } @EXPORT_FAILscip-perl cpan Icon-FamFamFam-Silk 0.002001003 Scalar/Util/`@EXPORT_FAIL`.) { # no XS loaded |
| 29 | my $pat = joinscip-perl cpan Icon-FamFamFam-Silk 0.002001003 Scalar/Util/join().("|", @EXPORT_FAILscip-perl cpan Icon-FamFamFam-Silk 0.002001003 Scalar/Util/`@EXPORT_FAIL`.); |
| 30 | if (my ($err) = grepscip-perl cpan Icon-FamFamFam-Silk 0.002001003 Scalar/Util/grep(). { /^($pat)$/ } @_scip-perl cpan Icon-FamFamFam-Silk 0.002001003 Scalar/Util/`@_`. ) { |
| 31 | requirescip-perl cpan Icon-FamFamFam-Silk 0.002001003 Scalar/Util/require(). Carp; |
| 32 | Carp::croakscip-perl cpan Icon-FamFamFam-Silk 0.002001003 Carp/croak().("$err is only available with the XS version of Scalar::Util"); |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | if (grepscip-perl cpan Icon-FamFamFam-Silk 0.002001003 Scalar/Util/grep(). { /^(weaken|isweak)$/ } @_scip-perl cpan Icon-FamFamFam-Silk 0.002001003 Scalar/Util/`@_`. ) { |
| 37 | requirescip-perl cpan Icon-FamFamFam-Silk 0.002001003 Scalar/Util/require(). Carp; |
| 38 | Carp::croakscip-perl cpan Icon-FamFamFam-Silk 0.002001003 Carp/croak().("Weak references are not implemented in the version of perl"); |
| 39 | } |
| 40 | |
| 41 | if (grepscip-perl cpan Icon-FamFamFam-Silk 0.002001003 Scalar/Util/grep(). { /^(isvstring)$/ } @_scip-perl cpan Icon-FamFamFam-Silk 0.002001003 Scalar/Util/`@_`. ) { |
| 42 | requirescip-perl cpan Icon-FamFamFam-Silk 0.002001003 Scalar/Util/require(). Carp; |
| 43 | Carp::croakscip-perl cpan Icon-FamFamFam-Silk 0.002001003 Carp/croak().("Vstrings are not implemented in the version of perl"); |
| 44 | } |
| 45 | |
| 46 | @_scip-perl cpan Icon-FamFamFam-Silk 0.002001003 Scalar/Util/`@_`.; |
| 47 | } |
| 48 | |
| 49 | sub openhandlescip-perl cpan Icon-FamFamFam-Silk 0.002001003 Scalar/Util/openhandle(). ($) { |
| 50 | my $fh = shiftscip-perl cpan Icon-FamFamFam-Silk 0.002001003 Scalar/Util/shift().; |
| 51 | my $rt = reftypescip-perl cpan Icon-FamFamFam-Silk 0.002001003 Scalar/Util/reftype().($fh) || ''; |
| 52 | |
| 53 | return definedscip-perl cpan Icon-FamFamFam-Silk 0.002001003 Scalar/Util/defined().(filenoscip-perl cpan Icon-FamFamFam-Silk 0.002001003 Scalar/Util/fileno().($fh)) ? $fh : undef |
| 54 | if $rt eq 'IO'; |
| 55 | |
| 56 | if (reftypescip-perl cpan Icon-FamFamFam-Silk 0.002001003 Scalar/Util/reftype().(\$fh) eq 'GLOB') { # handle openhandle(*DATA) |
| 57 | $fh = \(my $tmp=$fh); |
| 58 | } |
| 59 | elsif ($rt ne 'GLOB') { |
| 60 | return undef; |
| 61 | } |
| 62 | |
| 63 | (tiedscip-perl cpan Icon-FamFamFam-Silk 0.002001003 Scalar/Util/tied().(*$fh) or definedscip-perl cpan Icon-FamFamFam-Silk 0.002001003 Scalar/Util/defined().(filenoscip-perl cpan Icon-FamFamFam-Silk 0.002001003 Scalar/Util/fileno().($fh))) |
| 64 | ? $fh : undef; |
| 65 | } |
| 66 | |
| 67 | 1; |
| 68 | |
| 69 | __END__ |
| 70 | |
| 71 | #line 283 |