User Tools

Site Tools


code snippets

get base name and directory name from a file name

use File::Basename; # for fileparse
use File::Spec; # for rel2abs

# By default, the filename is not converted to absolute path.
# It has to be done manually if necessary.
# Note that the directory name contains '/' at the end. 
my ($base_name, $dir) = fileparse(File::Spec->rel2abs( $fname));



frequently used perl modules

Some perl modules that I frequently use and find useful.

use strict;
use warnings;
use autodie;
use Getopt::Long;
use Data::Dumper;  # for debugging purposes
use POSIX;         # for getting date and time
use Sys::Hostname; # for hostname
use File::Path qw(make_path);
use File::Basename qw(dirname);
use File::Spec;    # for rel2abs
use File::Spec::Functions qw(catdir catfile);
use List::Util qw(min);
use List::MoreUtils qw(uniq);
use Set::CrossProduct;  # for doing cross products
use Archive::Extract;    # to extract tar gzipped files
use 5.10.0;
perl_notes.txt · Last modified: 2024/01/03 22:05 by raju