++ed by:
Matthew Musgrove


File::LinkDir - Create links in one directory for files in another


  use File::LinkDir;
  my $linkdir = File::LinkDir->new( 'source' => '/path/to/dir', 'dest' => '/dest/path', 'hard' => 1, 'recursive' => 1 );
  $linkdir->init( 'source' => '/new/path', 'dest' => '/new/dest', );


By default, File::LinkDir will create symlinks in the destination directory for all top-level files, directories or symlinks found in the source directory. This is very useful for keeping the dot files in your $HOME under version control. A typical use case:

  use File::LinkDir;
  my $linkdir = File::LinkDir->new( 'source' => '.', 'dest' => '~' );



Creates a new File::LinkDir object. This will call init() to set the options unless you pass 'skipinit' as the first argument.


Initializes the object according to the options that were passed. This is automatically called by new() but can be called if you want to reuse the object for other directories.


Creates the links based on the options that were used in new() and/or init().



dryrun => 1

Prints what would have been done without actually doing it.


source => DIR

The source directory.


dest => DIR

The destination directory.


recursive => 1

With recursive => 1, it will not create symlinks to subdirectories found in the source directory. It will instead recurse into them and create symlinks for any files or symlinks it finds. Any subdirectories not found in the destination directory will be created. This approach is useful for destination directories where programs or users other than yourself might add things to subdirectories which you don't want ending up in your working tree implicitly. /etc is a good example.

In both cases, symlinks from the source directory will be copied as-is. This makes sense because the symlinks might be relative.


ignore => RX

RX is a regex matching files to ignore. If ignore => 1 is not specified, it defaults to ignoring .git (plus .gitignore, .gitmodules, etc, but not .gitconfig) and .svn directories and their contents.


addignore => RX

Like ignore => RX but doesn't replace the default.


force => 1

Remove and/or overwrite existing files/dirs.


hard => 1

Creates hard links instead of symlinks.


Hinrik Örn Sigurðsson, <hinrik.sig@gmail.com> Matthew Musgrove, <mr.muskrat@gmail.com>


Please report any bugs or feature requests to bug-file-linkdir at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=File-LinkDir. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.


You can find documentation for this module with the perldoc command.

    perldoc File::LinkDir

You can also look for information at:


Copyright (c) 2009-2010 Hinrik Örn Sigurðsson and Matthew Musgrove


This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.

Hosting generously
sponsored by Bytemark