⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 util.pm

📁 source of perl for linux application,
💻 PM
字号:
package Test::Harness::Util;use strict;use vars qw($VERSION);$VERSION = '0.01';use File::Spec;use Exporter;use vars qw( @ISA @EXPORT @EXPORT_OK );@ISA = qw( Exporter );@EXPORT = ();@EXPORT_OK = qw( all_in shuffle blibdirs );=head1 NAMETest::Harness::Util - Utility functions for Test::Harness::*=head1 SYNOPSISUtility functions for Test::Harness::*=head1 PUBLIC FUNCTIONSThe following are all available to be imported to your module.  No symbolsare exported by default.=head2 all_in( {parm => value, parm => value} )Finds all the F<*.t> in a directory.  Knows to skip F<.svn> and F<CVS>directories.Valid parms are:=over=item startStarting point for the search.  Defaults to ".".=item recurseFlag to say whether it should recurse.  Default to true.=back=cutsub all_in {    my $parms = shift;    my %parms = (        start => ".",        recurse => 1,        %$parms,    );    my @hits = ();    my $start = $parms{start};    local *DH;    if ( opendir( DH, $start ) ) {        my @files = sort readdir DH;        closedir DH;        for my $file ( @files ) {            next if $file eq File::Spec->updir || $file eq File::Spec->curdir;            next if $file eq ".svn";            next if $file eq "CVS";            my $currfile = File::Spec->catfile( $start, $file );            if ( -d $currfile ) {                push( @hits, all_in( { %parms, start => $currfile } ) ) if $parms{recurse};            }            else {                push( @hits, $currfile ) if $currfile =~ /\.t$/;            }        }    }    else {        warn "$start: $!\n";    }    return @hits;}=head1 shuffle( @list )Returns a shuffled copy of I<@list>.=cutsub shuffle {    # Fisher-Yates shuffle    my $i = @_;    while ($i) {        my $j = rand $i--;        @_[$i, $j] = @_[$j, $i];    }}=head2 blibdir()Finds all the blib directories.  Stolen directly from blib.pm=cutsub blibdirs {    my $dir = File::Spec->curdir;    if ($^O eq 'VMS') {        ($dir = VMS::Filespec::unixify($dir)) =~ s-/\z--;    }    my $archdir = "arch";    if ( $^O eq "MacOS" ) {        # Double up the MP::A so that it's not used only once.        $archdir = $MacPerl::Architecture = $MacPerl::Architecture;    }    my $i = 5;    while ($i--) {        my $blib      = File::Spec->catdir( $dir, "blib" );        my $blib_lib  = File::Spec->catdir( $blib, "lib" );        my $blib_arch = File::Spec->catdir( $blib, $archdir );        if ( -d $blib && -d $blib_arch && -d $blib_lib ) {            return ($blib_arch,$blib_lib);        }        $dir = File::Spec->catdir($dir, File::Spec->updir);    }    warn "$0: Cannot find blib\n";    return;}1;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -