MDK::Common::File - miscellaneous file/filename manipulation functions
use MDK::Common::File qw(:all);
returns the dirname/basename of the file name
returns the files contents: in scalar context it returns a single string, in array context it returns the lines.
If no file is found, undef is returned
same as cat_ but dies when something goes wrong
cat_
same as C(<cat_>) but reads utf8 encoded strings
same as C(<cat_or_die>) but reads utf8 encoded strings
returns the file content: in scalar context it returns a single string, in array context it returns the lines
creates a file and outputs the list (if the file exists, it is clobbered)
same as C(<output>) but writes utf8 encoded strings
likes output() but prevents insecured usage (it dies if somebody try to exploit the race window between unlink() and creat())
add the LIST at the end of the file
just like output but creates directories if needed
output
same as output_p but sets FILENAME permission to PERMISSION (using chmod)
output_p
creates the directory (make parent directories as needed)
remove the files (including sub-directories)
just like "cp -f"
just like "cp -af"
just like "cp -afx"
same as link/symlink/rename but removes the destination file first
ensure the file exists, set the modification time to current time
returns all the file in directory (except "." and "..")
returns all the files in directory and the sub-directories (except "." and "..")
simple version of glob: doesn't handle wildcards in directory (eg: */foo.c), nor special constructs (eg: [0-9] or {a,b})
glob
executes the code for each line of the file. You can know the end of the file is reached using eof
eof
expand the symlinks in the absolute filename: expand_symlinks("/etc/X11/X") gives "/usr/bin/Xorg"
expand_symlinks("/etc/X11/X")
opens the file and returns the file handle. If the file is not found, tries to gunzip the file + .gz
cat_ alike. If the file is not found, tries to gunzip the file + .gz
MDK::Common
To install MDK::Common, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MDK::Common
CPAN shell
perl -MCPAN -e shell install MDK::Common
For more information on module installation, please visit the detailed CPAN module installation guide.