Please explain your input and the function returned or expected output...
k_manimuthu
Junior Poster in Training
93 posts since Jun 2009
Reputation Points: 55
Solved Threads: 24
I don't know the how the reply helpful to you. But I hope you will get a bit. Below I place the sample code for you. For better understand purpose do the below steps and execute the program
1) Create path like 'e:\dani\delim\path\example'
2) Place the perl program
3) Create the file like 'e:\dani\japh.pl'
4) Run the perl file.From the result, I'm going to extract the path using Perl's substr and index functions. From the result, I'm going to extract the path using Perl's substr and index functions.
No need to use substr function here. Better you have use the 'File::Basename' module. That gives the base directory and file name.
The 'abs_path' gives the absolute path of the given file.
use File::Basename;
use Cwd 'abs_path';
# Get the Absolute path a particular file
my $path = abs_path("../../../japh.pl" );
print "\nabs path : ", $path;
# Get the base directory of the file
my $base_dir = dirname($path);
print "\nbase path : ", $base_dir;
# Append another one file to the base dir
my $another_file = "$base_dir/myfile";
print "\nAnother file : ", $another_file;
k_manimuthu
Junior Poster in Training
93 posts since Jun 2009
Reputation Points: 55
Solved Threads: 24