Mathias Weidner > Directory-Organize > Directory::Organize

Download:
Directory-Organize-v0.9.6.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: v0.9.5   Source  

NAME ^

Directory::Organize - create and find directories organized by date

VERSION ^

This documentation refers to Directory::Organize version 0.8.

SYNOPSIS ^

  use Directory::Organize;

  $do = new Directory::Organize($basedir);

  @directories = $do->get_descriptions(\%constraints);

  $path = $do->new_dir($description);

  $do->set_pattern($pattern);

  $do->set_time_constraint('<',$year,$month,$day);

  $do->set_today($day,$month,$year);

METHODS ^

new()

  use Directory::Organize;

  $do = new Directory::Organize($basedir);

get_descriptions()

This functions returns an array of arrays of the form

  ([ path1, description1 ],
   ...
   [ pathn, descriptionn ],
  )

It searches all subdirectories three levels below $basedir for a file named .project. The returned array contains the relative path from the base directory and the first line of the .project file as description. This array is sorted descending by path.

  @directories = $do->get_descriptions();

new_dir()

This function creates a new directory according to the current date or the date given with set_doday() and creates a file named .project in the newly created directory containing the given description.

If there already exists a directory for the given date, it will add a suffix to the day. Therefore if you call this functions three times with the date 2009-05-25, the first directory created will be 2009/05/25, the second will be 2009/05/25a and the third 2009/05/25b.

The function returns the path of the created directory.

  $path = $do->new_dir($description);

set_pattern()

This function sets a pattern to constrain the list of subdirectories returned by the next call of get_descriptions().

  $do->set_pattern($pattern);

set_time_constraint()

This function sets a constraint for the time of creation of the project directories returned with get_descriptions();

  $do->set_time_constraint($op,$year,$month,$day);
  $do->set_time_constraint($op,$year,$month);
  $do->set_time_constraint($op,$year);

The argument $op specifies the operator and may be one of '=', '<' or '>' depending on whether the time constraint should be in, before or after the given time. $year denotes the year, $month the month (1..12) and $day the day (1..31) that the operator should be applied to. If $day or $month are omitted, the operator applies to the whole month or year.

set_today()

Specifies the date to be used the next time when creating a new directory with new_dir(). Arguments may be

none

to set the current date

  $do->set_today();
a day

to set another day in this month and year.

  $do->set_today($day);
a day and a month

to set another day and month in this year.

  $do->set_today($day,$month);
a day, a month and a year

to set an arbitrary date.

  $do->set_today($day,$month,$year);

AUTHOR ^

Mathias Weidner

LICENCE AND COPYRIGHT ^

Copyright (c) 2009 Mathias Weidner (mathias@weidner.in-bad-schmiedeberg.de). All rights reserved.

This module is free software; you can redistribute and/or modify it under the same terms as Perl itself. See perlartistic.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

syntax highlighting: