| NetSDS::Util::File(3pm) | User Contributed Perl Documentation | NetSDS::Util::File(3pm) | 
NetSDS::Util::File - file related utilities
        use NetSDS::Util::File qw(file_read);
        my $passwd = file_read('/etc/passwd');
        file_move('/etc/passwd', '/tmp/find_this');
"NetSDS::Util::File" module contains some routines for files and directories processing tasks like creating, reading, writing, copying and moving files and catalogs.
This module of cource uses such well known things like File::Spec, File::Path, File::Copy and others.
Returns: 1 if it's file handle or undef otherwise
        if (is_handle($var)) {
                reset_handle($fh);
        }
    
  Returns: nothing
This function tries to set filehandle to begin of file and set binmode on it.
        my $fh = file_open('/etc/passwd');
        ...
        do something with file
        ...
        reset_handle($fh); # We can read it from the beginning
    
  Returns: file handle
This function provides unified API for opening files.
        my $f = file_open('/etc/passwd');
    
  Returns: scalar content of file
This function provides ability to read file content to scalar variable.
        my $data = file_read('/etc/passwd');
        print "Passwords file: $data\n";
    
  Returns: length of written data or undef in case of error
        my $data = 'This should be file';
        file_write('/tmp/file.dat', $data);
    
  Returns:
This function copy file to new location.
Returns: 1 or undef
This function moves old file to new location.
Returns: directory name or undef
        # Will create all parent catalogs if necessary
        dir_create('/var/log/NetSDS/xxx');
    
  Returns: dir name or undef if error
        print "We need no libs!";
        dir_delete('/usr/lib');
    
  Returns: list of files in catalog
        my @logs = @{ dir_read('/var/log/httpd', 'log') };
        print "Logs are: " . join (', ', @logs);
    
  Returns: list of files with extension from parameters
        my $tpls = dir_read_recursive('/etc/NetSDS', 'tmpl');
        foreach my $tpl (@$tpls) {
                pritn "Template: $tpl\n";
        }
    
  Returns: 1 if ok, undef otherwise
This function calls system() with given parameters and returns 1 if everything happened correctly (program executed and returned correct result).
        if (exec_external('/bin/rm', '-rf', '/')) {
                print "Hey! We removed the world!";
        }
    
  None yet
Unknown yet
IO::Handle, IO::Scalar, IO::File, File::Spec, File::Copy, File::Path, system()
1. Implement more detailed error handling
Valentyn Solomko <pere@pere.org.ua>
Michael Bochkaryov <misha@rattler.kiev.ua>
| 2022-11-20 | perl v5.36.0 |