NAME
SysAdmin::File - Perl IO::File wrapper module..
SYNOPSIS
use SysAdmin::File;
## Declare file object
my $file_object = new SysAdmin::File(name => "/tmp/test.txt");
## Read file and dump contents to array reference
my $array_ref = $file_object->readFile();
foreach my $row (@$array_ref){
print "Row $row\n";
}
## Write to file
my @file_contents = ("First Line", "Second Line");
$file_object->writeFile(\@file_contents);
## Append file
my @file_contents_append = ("Third Line", "Fourth Line");
$file_object->appendFile(\@file_contents_append);
## Check File Exist
my $file_exist = $file_object->fileExist();
if($file_exist){
print "File exists\n";
}
## Declare directory object
my $directory_object = new SysAdmin::File(name => "/tmp");
## Check Directory Exist
my $directory_exist = $directory_object->directoryExist();
if($directory_exist){
print "Directory exists\n";
}
DESCRIPTION
This is a sub class of SysAdmin. It was created to harness Perl Objects and keep code abstraction to a minimum.
SysAdmin::File uses IO::File to interact with files.
METHODS
new()
## Declare file object
my $file_object = new SysAdmin::File(name => "/tmp/test.txt");
readFile()
## Read file and dump contents to array reference
my $array_ref = $file_object->readFile();
foreach my $row (@$array_ref){
print "Row $row\n";
}
writeFile()
## Write to file
my @file_contents = ("First Line", "Second Line");
$file_object->writeFile(\@file_contents);
appendFile()
## Append file
my @file_contents_append = ("Third Line", "Fourth Line");
$file_object->appendFile(\@file_contents_append);
fileExist()
## Check File Exist
my $file_exist = $file_object->fileExist();
directoryExist()
## Declare directory object
my $directory_object = new SysAdmin::File(name => "/tmp");
## Check Directory Exist
my $directory_exist = $directory_object->directoryExist();
if($directory_exist){
print "Directory exists\n";
}
SEE ALSO
IO::File - supply object methods for filehandles
AUTHOR
Miguel A. Rivera
COPYRIGHT AND LICENSE
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.