Tie::FileSystem - Access file system via a Perl hash


Tie-FileSystem documentation  | view source Contained in the Tie-FileSystem distribution.

Index


NAME

Top

Tie::FileSystem - Access file system via a Perl hash

SYNOPSIS

Top

  use Tie::FileSystem;
  use Data::Dumper;

  my %data;
  tie %data, "Tie::FileSystem", ( 'dir' => "/" );
  print Dumper($data{'etc'}{'passwd'});

DESCRIPTION

Top

Tie::FileSystem represents file system as a Perl hash. Each hash key corresponds to name of a directory or a file. For example, for a file "/etc/passwd" it will be $data{'etc'}{'passwd'}. Contents of the file "/etc/passwd" becomes a value corresponding to the $data{'etc'}{'passwd'}.

Standard handling procedure for directories is to store a listing of files in the directory as keys. Standard procedure for files is to store a contents of the file in the scalar value.

For certain files with known structure it is possible to define subroutines for special handling. "Tie::FileSystem::System" defines subroutines for handling system files and, for starters, has 'passwd' handling subroutine. "/etc/passwd" can be represented asa hash with following structure: $data{'etc'}{'passwd'}{$username}{$field}.

Options

  tie %data, "Tie::FileSystem",
    ( 'dbg' => 0, 'buf_size' => 10, 'dir' => "/" );

  'dbg' - level of debug output
    0 - 'SILENT', default # No output at all, ERRORs are suppressed
    1 - 'ERROR'           # ERRORs are printed to STDERR
    2 - 'WARNING'         # WARNINGs are printed to STDERR
    3 - 'INFO'            # Information messages
    4 - 'D:IN/OUT'        # Important variables
    5 - 'D:LOGIC'         # Logical desicions
    6 - 'D:VARS'          # Variables

  'buf_size' - buffer limit for file reading

  'dir' - directory to tie to

Public Methods

None.

PLATFORMS

Top

Debian 3.1, Perl, v5.8.8.

Windows XP, ActiveState Perl, v5.8.8.

CAVEATS

Top

The module is read only and does not permit overwrite or delete files.

Under Windows '/' corresponds to 'C:'.

If you try to tie hash %data to '/' and then print Dumper(%data), module will traverse the entire file system on demand!

BUGS

Top

None known.

AUTHOR

Top

Vadim V. Kouevda, initdotd@gmail.com

LICENSE and COPYRIGHT

Top

WARRANTY

Top

Module comes with ABSOLUTELY NO WARRANTY. For details, see the license.

AVAILABILITY

Top

The latest version can be obtained from CPAN

SEE ALSO

Top

Tie::FileSystem::System(3), Tie::File(3)


Tie-FileSystem documentation  | view source Contained in the Tie-FileSystem distribution.