I am trying to output a file in perl.
I open the file and output like this..
open(my $out, ">", "output.html") or die "Can't open output.txt: $!";
print $out "something!";
Which works perfect. If I change it to this
open(my $out, ">", "c:\somedirectory\output.html") or die "Can't open output.txt: $!";
print $out "something!";
It does run fine(I do not get the ‘Can’t open output.txt’ message) but when I look in the directory the file I just output isn’t there. If I leave it with no path the file is found in the bin.
What am I missing here? How do I get it to output another location.
Also.. I am running the .pl using this .bat file.
cd\
cd \xampp\perl\bin
perl "C:\somedirectory\languages.pl"
pause
Within double quotes,
\starts an escape sequence. Unrecognized escapes are simply ignored.You may double up the backslashes in order to let them pass through the double quotes.
You may use single quotes instead of double quotes, because escape sequences are not recognized within single quotes.
And a final option: the Win32 and NT APIs happily treat
/as directory separators just as well as\. While it may look odd, the following will work too: