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 8040617
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T03:57:29+00:00 2026-06-05T03:57:29+00:00

I am trying to read a file in the same directory as the Perl

  • 0

I am trying to read a file in the same directory as the Perl script as input and read from it in Windows using Perl.

Code:

$inputFile =  getcwd . "/" . <STDIN>;
open (FILE, chomp($inputFile)) or die "Cannot open $inputFile: $!\n";   
@lines = <FILE>;
print "@lines\n";

The error I get is:

C:/Documents and Settings/username/workspace/test.pl  No such file or directory

Even though that file definitely does exist in that exact form in that exact directory. I’ve also tried putting the “Documents and Settings” in quotes.

  • 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-06-05T03:57:31+00:00Added an answer on June 5, 2026 at 3:57 am

    The return value from chomp is not the chomped value. Factor out the chomp to before open and you should be fine.

    The getcwd is needless, by the way; the concept of current directory means where to look in the absence of a full path.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to run genhtml using perl.exe from Cygwin in Windows. I have installed
I am trying to upload a file to web server and read the same.
I am trying to read from file: The file is multiline and basically i
I'm trying to get ghostscript to render a pdf file from a Windows box.
I'm trying to read a 16-bit greyscale TIFF file (BitsPerSample=16) using a small C
I am trying to read a file(temp.txt) placed under /root directory on remote host(ubuntu)
I am trying to read file and split its line to get some context(Computer
I am trying to read a file (made a simple .txt file on my
I'm trying to read the file DictionaryWords in the image below How do I
I'm trying to read a file that exists in the following location of my

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.