Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 647529
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:43:56+00:00 2026-05-13T21:43:56+00:00

I am trying to output a file in perl. I open the file and

  • 0

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
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T21:43:57+00:00Added an answer on May 13, 2026 at 9:43 pm

    Within double quotes, \ starts an escape sequence. Unrecognized escapes are simply ignored.

    print "abc\tdef";
    # abc     def
    print "c:\somedirectory\output.html";
    # c:somedirectoryoutput.html
    print qq(c:\somedirectory\output.html);
    # c:somedirectoryoutput.html
    

    You may double up the backslashes in order to let them pass through the double quotes.

    print "c:\\somedirectory\\output.html";
    # c:\somedirectory\output.html
    print qq(c:\\somedirectory\\output.html);
    # c:\somedirectory\output.html
    

    You may use single quotes instead of double quotes, because escape sequences are not recognized within single quotes.

    print 'c:\somedirectory\output.html';
    # c:\somedirectory\output.html
    print q(c:\somedirectory\output.html);
    # c:\somedirectory\output.html
    

    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:

    open(my $out, ">", "C:/somedirectory/output.html");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a perl code for processing file 'Output.txt' which has below Content.
I am trying to modify a file which is set up like this: chr
I am trying to redirect perl system command to output file with the following
I was trying to code this problem in fortran. The output file contains the
I'm trying to output each line in a csv file, and it seems like
I'm trying to capture dvdauthor's output to a file. So far i found this
I am trying to log the input/output of expect to an open file. The
Trying to figure this out. I am trying to execute a perl script within
I'm trying to parse an html output file from a program called mirdeep. I
I have an XML file, part of which looks like this: <wave waveID=1> <well

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.