$ perl -le " print -e qq'C:/\0blah'
1
$ perl -MPath::Class -le " print file(qq'C:/\0blah')->resolve "
C:\
| [reply] |
No, my program get path from the user as parameter and need to check if the path is valid - if yes then create the folder.
| [reply] |
Define 'valid'. One approach would be to 'try it and see'. Attempt the create, if that succeeds, check to verify the directory exists1. In this case, 'valid' means being able to be created.
If you define what you mean by 'valid', it may help with the responses.
Footnotes:
- 1 -
Winding back if it doesn't exist might be fun...
Updates:
- +10 minutes - Update formatting and footnotes, and added a more generic response.
| [reply] |
I misunderstood the OP's question. In this case, I agree with MidLifeXis, try create a dir.
A tool you can use can be Win32::CreateDirectory, check the return value and message the user afterward
| [reply] |
I didn't successes to use the following regular expressions
my $dir = "c:\\temp\\%1111 323232?";
if ($dir =~ m/^[a-z]:\\(?:[^\\/:*?"<>|\r\n]+\\)*[^\\/:*?"<>|\r\n]*$/i)
{
print "Valid Path\n";
} else {
print "Not Valid Path\n";
}
Please advise - as i wrote i get Path from the user and i need to print error if isn't valid path.
| [reply] [d/l] |