I'm still new to perl, so apologies for the rookie question!
I'm using glob to reference the home directory.
The first part of the script names a path to a folder and confirms that it exists:
$path = glob("~/Desktop/Folder/nextFolder/file.txt");
if( !(-e "$path") ) {
print "Error: invalid path <$path>\n";
exit 1;
}
Initially I was just using the following script:
$path = "~/Desktop/Folder/nextFolder/file.txt";
if( !(-e "$path") ) {
print "Error: invalid path <$path>\n";
exit 1;
}
but it was throwing up the "Error: invalid path" error when executed.
I've read up on glob but I don't really understand it - I found this solution online and tried it, and it worked!
Can someone please explain what it's doing to allow the reference to the home directory? Why doesn't this work without it?
Let me know if this needs more information! Thank you!