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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:30:47+00:00 2026-05-27T11:30:47+00:00

I really should know this, but I’ve worked mainly with Linux, Mac OS X

  • 0

I really should know this, but I’ve worked mainly with Linux, Mac OS X and Windows which all use the forward slash (/) as a directory separator (Windows can use either \ or /.).

That means when I normally write programs in Perl, I can simply use / as the directory separator and everything is fine. However, I know that File::Spec is suppose to allow for the portability of file separators (whatever that means).

If I am on a system that does not use forward slashes as a directory separator, I understand that users expect to be able to input files with the default separators and see output with the default separators. (For example, a Windows user will input and expect output to be C:\Users\smith\Documents and not C:/Users/smith/Documents), but what does Perl do internally?

Can I, despite what the platform may use as a directory separator, simply use forward slashes when I’m dealing with files internally. For example, I have a directory $dir and a file called $file, and I want to open the file. Can I simply say $dir/file, or do I have to use File::Spec to concat the name for me?

In fact, do Perl programs require forward slashes in directory names? I’m writing a module, and will be delivering file names to the calling program. Should I give the file as /foo/bar/fubar or if the system uses colons like the early Macintosh OS, say :foo:bar:fubar?

  • 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-27T11:30:48+00:00Added an answer on May 27, 2026 at 11:30 am

    perlport says almost everything there is to say about this subject. That said, systems that can not accept / as the path separator are rare, and you might not have that much to gain from using File::Spec faithfully everywhere. But also be careful to distinguish internal and external uses of the directory separator. For example, this will work on Windows:

    open my $fh, '<', 'C:/some/directory/to/some/file';
    

    but this might not, because it needs to be processed by the Windows shell:

    system("C:/some/program.exe C:/some/program/argument.txt");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know this sounds really silly but what character encoding should I use for
I know this should be really simple, but im having trouble getting this to
I'm doing some coursework for uni, I really should know this but I am
Hi, I know this should be really simple but I am just too new
This is something I should really know, but I haven't done any db work
I know this is a really simple thing that I really should know but
I know this question should be really simple, but for some reason thoroughly understanding
Don't really know how to formulate the title, but it should be pretty obvious
I have an application which really should be installed, but does work fine when
This should be really simple, but I have tried many solutions posted on the

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.