Download Shareware and Freeware Software for Windows, Linux, Macintosh, PDA

line Home  |  About Us  |  Link To Us  |  FAQ  |  Contact

Serving Software Downloads in 976 Categories, Downloaded 29.868.508 Times

File::Wildcard 0.10

  Date Added: May 26, 2010  |  Visits: 789


Report Broken Link
Printer Friendly Version

Product Homepage
Download (73 downloads)

File::Wildcard is a Perl module for enhanced glob processing. SYNOPSIS use File::Wildcard; my $foo = File::Wildcard->new(path => "/home/me///core"); while (my $file = $foo->next) { unlink $file; } When looking at how various operating systems do filename wildcard expansion (globbing), VMS has a nice syntax which allows expansion and searching of whole directory trees. It would be nice if other operating systems had something like this built in. The best Unix can manage is through the utility program find. This module provides this facility to Perl. Whereas native VMS syntax uses the ellipsis "...", this will not fit in with POSIX filenames, as ... is a valid (though somewhat strange) filename. Instead, the construct "///" is used as this cannot syntactically be part of a filename, as you do not get three concurrent filename separators with nothing between (three slashes are used to avoid confusion with //node/path/name syntax). You dont have to use this syntax, as you can do the splitting yourself and pass in an arrayref as your path. The module also forms a regular expression for the whole of the wildcard string, and binds a series of back references ($1, $2 etc.) which are available to construct new filenames. new File::Wildcard-new( $wildcard, [,option => value,...]);> my $foo = File::Wildcard->new( path => "/home/me///core"); my $srcfnd = File::Wildcard->new( path => "src///*.cpp", match => qr(^src/(.*?).cpp$), derive => [src/$1.o,src/$1.hpp]); This is the constructor for File::Wildcard objects. At a simple level, pass a single wildcard string as a path. For more complicated operations, you can supply your own match regexp, or use the derive option to specify regular expression captures to form the basis of other filenames that are constructed for you. The $srcfnd example gives you object files and header files corresponding to C++ source files. Here are the options that are available: path This is the input parameter that specifies the range of files that will be looked at. This is a glob spec which can also contain the ellipsis /// (it could contain more than one ellipsis, but the benefit of this is questionable, and multiple ellipsi would cause a performance hit). Note that the path can be relative or absolute. new will do the right thing, working out that a path starting with / is absolute. In order to recurse from the current directory downwards, specify .///foo. As an alternative, you can supply an arrayref with the path constituents already split. If you do this, you need to tell new if the path is absolute. Include an empty string for an ellipsis. For example: foo///bar/*.c is equivalent to [foo,,bar,*.c] You can also construct a File::Wildcard without a path. A call to next will return undef, but paths can be added using the append and prepend methods. absolute This is ignored unless you are using a pre split path. If you are passing a string as the path, new will work out whether the path is absolute or relative. Pass a true value for absolute paths. If your original filespec started with / before you split it, specify absolute => 1. absolute is not required for Windows if the path contains a drive specification, e.g. C:/foo/bar. case_insensitive By default, the module will use Filesys::Type to determine whether the file system of your wildcard is defined. This is an optional module (see Module::Optional), and File::Wildcard will guess at case sensitivity based on your operating system. This will not always be correct, as the file system might be VFAT mounted on Linux or ODS-5 on VMS. Specifying the option case_insensitive explicitly forces this behaviour on the wildcard. Note that File::Wildcard will use the file system of the current working directory if the path is not absolute. If the path is absolute, you should specify the case_sensitivity option explicitly. exclude You can provide a regexp to apply to any generated paths, which will cause any matching paths not to be processed. If the root of a directory tree matches, no processing is done on the entire tree. This option can be useful for excluding version control repositories, e.g. exclude => qr/.svn/ match Optional. If you do not specify a regexp, you get all the files that match the glob; in addition, new will set up a regexp for you, to provide a capture for each wildcard used in the path. If you do provide a match parameter, this will be used instead, and will filter the results. derive Supply an arrayref with a list of derived filenames, which will be constructed for each matching file. This causes next to return an arrayref instead of a scalar. follow If given a true value indicates that symbolic links are to be followed. Otherwise, the symbolic link target itself is presented, but the ellipsis will not traverse the link. This module detects a looping symlink that points to a directory higher up, and will only present the tree once. ellipsis_order This can take one of the following values: normal, breadth-first, inside-out. The default option is normal. This controls how File::Wildcard handles the ellipsis. The default is a normal depth first search, presenting the name of each containing directory before the contents. The inside-out order presents the contents of directories first before the directory, which is useful when you want to remove files and directories (all O/S require directories to be empty before rmdir will work). See t/03_absolute.t as this uses inside-out order to tidy up after the test. Breadth-first is rarely needed (but I do have an application for it). Here, the whole directory contents is presented before traversing any subdirectories. Consider the following tree: a/ a/bar/ a/bar/drink a/foo/ a/foo/lish breadth-first will give the following order: qw(a/ a/bar/ a/foo/ a/bar/drink a/foo/lish). normal gives the order in which the files are listed. inside-out gives the following: qw(a/bar/drink a/bar/ a/foo/lish a/foo/ a/). sort By default, globbing returns the list of files in the order in which they are returned by the dirhandle (internally). If you specify sort => 1, the files are sorted into ASCII sequence (case insensitively if we are operating that way). If you specify a CODEREF, this will be used as a comparison routine. Note that this takes its operands in @_, not in $a and $b. debug and debug_output You can enable a trace of the internal states of File::Wildcard by setting debug to a true value. Set debug_output to an open filehandle to get the trace in a file. If you are submitting bug reports for File::Wildcard, attaching debug trace files would be very useful. debug_output defaults to STDERR. match my $foo_re = $foo->match; $foo->match(bar/core); This is a get and set method that gives access to the match regexp that the File::Wildcard object is using. It is possible to change the regex on the fly in the middle of a search (though I dont know why anyone would want to do this). append $foo->append(path => /home/me///*.tmp); appends a path to an objects todo list. This will be globbed after the object has finished processing the existing wildcards. prepend $srcfnd->prepend(path => $include_file); This is similar to append, but prepends the path to the todo list. In other words, the current wildcard operation is interrupted to serve the new path, then the previous wildcard operation is resumed when this is exhausted. next while (my $core = $foo->next) { unlink $core; } my ($src,$obj,$hdr) = @{$srcfnd->next}; The next method is an iterator, which returns successive files. Returns matching files if there was no derive option passed to new. If there was a derive option, returns an arrayref containing the matching filespec and all derived filespecs. The derived filespecs do not have to exist. Note that next maintains an internal cursor, which retains context and state information. Beware if the contents of directories are changing while you are iterating with next; you may get unpredictable results. If you are intending to change the contents of the directories you are scanning (with unlink or rename), you are better off deferring this operation until you have processed the whole tree. For the pending delete or rename operations, you could always use another File::Wildcard object - see the spike example below: all my @cores = $foo->all; all returns an array of matching files, in the simple case. Returns an array of arrays if you are constructing new filenames, like the $srcfnd example. Beware of the performance and memory implications of using all. The method will not return until it has read the entire directory tree. Use of the all method is not recommended for traversing large directory trees and whole file systems. Consider coding the traversal using the iterator next instead. reset reset causes the wildcard context to be set to re-read the first filename again. Note that this will cause directory contents to be re-read. Note also that this will cause the path to revert to the original path specified to new. Any additional paths appended or prepended will be forgotten. close Release all directory handles associated with the File::Wildcard object. An object that has been closed will be garbage collected once it goes out of scope. Wildcards that have been exhausted are automatically closed, (i.e. all was used, or c< next > returned undef). Subsequent calls to next will return undef. It is possible to call reset after close on the same File::Wildcard object, which will cause it to be reopened..

Requirements: No special requirements
Platforms: Linux
Keyword: Absolute Directory Files Filewildcard Libraries New Path Perl Module Programming Vms Wildcard Will Be
Users rating: 0/10

License: Freeware Size: 23.55 KB
More Reviews or Write Review

Libraries  -  Markup::MatchTree 1.0.0
Markup::MatchTree is a Perl module for building trees to be compared to Markup::Trees. SYNOPSIS use Markup::MatchTree; my $match_tree = Markup::MatchTree->new( no_squash_whitespace => @same_as_I_used_for_Markup__Tree);...
3.07 KB  
Libraries  -  Variable::Strongly::Typed 1.1.0
Variable::Strongly::Typed is a Perl module to let some variables be strongly typed. SYNOPSIS use Variable::Strongly::Typed; my $int :TYPE(int); # must have an int value my $float :TYPE(float); # must have a float value my $string...
10.24 KB  
Libraries  -  Regexp::Wildcards 0.06
Regexp::Wildcards is a Perl module that converts wildcard expressions to Perl regular expressions. SYNOPSIS use Regexp::Wildcards qw/wc2re/; my $re; $re = wc2re a{b?,c}* => unix; # Do it Unix style. $re = wc2re a?,b* => win32; # Do it...
9.22 KB  
Libraries  -  MMDS::Properties 1.902
MMDS::Properties Perl module contains flexible properties handling for MMDS. use MMDS::Properties; my $cfg = new MMDS::Properties; # Preset a property. $cfg->set_property("config.version", "1.23"); # Parse a properties file....
409.6 KB  
Libraries  -  Apache::TestUtil 1.29
Apache::TestUtil Perl module contains utility functions for writing tests. SYNOPSIS use Apache::Test; use Apache::TestUtil; ok t_cmp("foo", "foo", "sanity check"); t_write_file("filename", @content); my $fh = t_open_file($filename);...
153.6 KB  
Libraries  -  Alien Perl module 0.91
Alien Perl module package contains external libraries wrapped up for your viewing pleasure! SYNOPSIS perldoc Alien; Alien is a package that exists just to hold together an idea, the idea of Alien:: packages, so there is no code here, just...
10.24 KB  
Libraries  -  NDBM_File 5.8.8
NDBM_File is a Perl module that allows tied access to ndbm files. SYNOPSIS use Fcntl; # For O_RDWR, O_CREAT, etc. use NDBM_File; tie(%h, NDBM_File, filename, O_RDWR|O_CREAT, 0666) or die "Couldnt tie NDBM file filename: $!; aborting"; #...
12.2 MB  
Libraries  -  ODBM_File 5.8.8
ODBM_File is a Perl module to allow tied access to odbm files. SYNOPSIS use Fcntl; # For O_RDWR, O_CREAT, etc. use ODBM_File; # Now read and change the hash $h{newkey} = newvalue; print $h{oldkey}; ... untie %h; ODBM_File establishes...
12.2 MB  
Libraries  -  XML::SAX::Machine 0.41
XML::SAX::Machine is a Perl module that can manage a collection of SAX processors. SYNOPSIS ## Note: See XML::SAX::Pipeline and XML::SAX::Machines first, ## this is the gory, detailed interface. use My::SAX::Machines qw( Machine ); use...
43.01 KB  
Libraries  -  OpenGeoDB Perl module 0.4
OpenGeDB Perl module is a module to access the OpenGeoDB database and calculate all ZIP codes in a certain radius..
3.07 KB  
Programming  -  FLEX-db Digital Asset Manager 3.0.9
FLEX-db - an enterprise Digital Asset Manager (DAM). It ingests and links metadata with files, creates thumbnails, and processes files using business rules. FLEX-db has a JSP client, Java app server for file input and output and an EJB metadata...
21.57 MB  
Programming  -  Libicom 0.9.0
The libicom library is a character based dynamicly linked library for Linux. It is used to remotely control the Icom IC-R8500 wide band receiver via an RS232 link. All call and return parameters to the control functions are character string based....
20.48 KB  
Programming  -  dotdesktop 0.3
Dotdesktop library provides ability to parse desktop entry file and access the information in a convenient way. Desktop entry file format is defined by, it is used to describe information about an application such as the name and...
327.68 KB  
Programming  -  Cedalion for Linux 0.2.6
Cedalion is a programming language that allows its users to add new abstractions and define (and use) internal DSLs. Its innovation is in the fact that it uses projectional editing to allow the new abstractions to have no syntactic limitations.
471.04 KB  
Programming  -  libyasl 0.2
Libyasl is a C++ class library to easily realize TCP/UDP/Multicast clientsand servers in IPv4 and IPv6 environments under GNU/Linux systems.
143.36 KB  
Libraries  -  wolfSSL 3.11.0
The wolfSSL embedded SSL/TLS library is a lightweight SSL library written in ANSI standard C and targeted for embedded and RTOS environments - primarily because of its small size, speed, and feature set. It is commonly used in standard operating...
2.73 MB  
Libraries  -  EuGTK 4.8.9
Makes it easy to develop good- looking, fast, cross-platform programs that run on Linux, OS X, and Windows. Euphoria is a very fast interpreted/compiled language with straight-forward syntax. EuGTK allows programming in a clean, object-oriented...
10.68 MB  
Libraries  -  Linux User Group Library Manager 1.0
The LUG Library Manager is a project to help Linux User Groups start their own library. A LUG library is helpful to the community at large because it increases access to information, and gives everyone the opportunity to become more knowledgeable.
5.35 KB  
Libraries  -  Module::MakefilePL::Parse 0.12
Module::MakefilePL::Parse is a Perl module to parse required modules from Makefile.PL. SYNOPSIS use Module::MakefilePL::Parse; open $fh, Makefile.PL; $parser = Module::MakefilePL::Parse->new( join("", ) ); $info = $parser->required;...
8.19 KB  
Libraries  -  sqlpp 0.06
sqlpp Perl package is a SQL preprocessor. sqlpp is a conventional cpp-alike preprocessor taught to understand SQL ( PgSQL, in particular) syntax specificities. In addition to the standard #define/#ifdef/#else/#endif cohort, provides also...
10.24 KB