ConMan318
August 8th, 2008, 11:07 PM
I have searched this as well as I can, and I can't find it. How can I retrieve the path to the current user's home directory? I found a solution in Python on this site, but can't find any for Perl.
I need to check if a file in the user's home folder exists, and be able to read/write to it. Using the file test
if(-e ~/existingFile){ # -e checks if a file exists
print "Exists\n";
} else {
print "Doesn't exist\n";
}
always says the file doesn't exist, though replacing '~' with '/home/connor' shows it as existing.
Problem is that I want this program to work on any Linux machine using the logged-in user's home directory.
Thanks in advance.
I need to check if a file in the user's home folder exists, and be able to read/write to it. Using the file test
if(-e ~/existingFile){ # -e checks if a file exists
print "Exists\n";
} else {
print "Doesn't exist\n";
}
always says the file doesn't exist, though replacing '~' with '/home/connor' shows it as existing.
Problem is that I want this program to work on any Linux machine using the logged-in user's home directory.
Thanks in advance.