Last active
December 18, 2015 22:18
-
-
Save mishin/5853196 to your computer and use it in GitHub Desktop.
make file in home directory for log job in a day
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!perl | |
use Modern::Perl; | |
use POSIX qw(strftime); | |
use File::Slurp; | |
use File::Path qw(make_path); | |
use File::Spec::Functions qw(catdir catfile); | |
use File::HomeDir; | |
main(); | |
# Make path tree and file | |
sub main { | |
my $work_path = File::HomeDir->my_documents; | |
my $date = strftime( '%d%m%Y', localtime(time) ); | |
my $job_dir = catdir( $work_path, 'job', $date ); | |
make_path($job_dir); # if !-d $job_dir; | |
my $file = catfile( $job_dir, $date . '_nb.txt' ); | |
write_file($file) if !-f $file;# write_file( $file, { no_clobber => 1, err_mode => 'quiet' }, '' ); | |
say "file $file written successfully!"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment