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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:56:35+00:00 2026-05-28T18:56:35+00:00

if (-e $ENV{MYHOME}/link) { system(rm $ENV{MYHOME}/link); } This is the code being used to

  • 0
if (-e "$ENV{MYHOME}/link") {
    system("rm $ENV{MYHOME}/link");
}

This is the code being used to check if a symlink exists and remove it if it does.

I am tracking a bug where this code does not work. I have not been able to figure it out as of now, but what is happening is that this code is unable to remove the symlink, which results in a ‘File exists’ error down the line.

I wanted to check if there is some fundamental flaw with this technique? I also read about http://perldoc.perl.org/functions/unlink.html but would like to know if the current approach is not recommended due to some reason?

  • 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-28T18:56:36+00:00Added an answer on May 28, 2026 at 6:56 pm

    Just use:

    if ( -l "$ENV{MYHOME}/link" ) {
        unlink "$ENV{MYHOME}/link"
            or die "Failed to remove file $ENV{MYHOME}/link: $!\n";
    }
    

    If the unlink fails, it’ll say why. The -l asks if the target is a link. The -e asks if the file exists. If your link is to a non-existent file, it’ll return false, and your code would fail to remove the link.

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

Sidebar

Related Questions

To run a program with custom env settings, we do this on Linux $
Is there a good Flex IDE/development env that works on Ubuntu? Where can this
Env: .NET 1.1 I got into this situation. Where I need to give a
Here is a discussion of using Rails.env instead of RAILS_ENV , since it's being
Attacklab.wmd_env.buttons=Attacklab.wmd_env.buttons||_4; what does the || do in this case? Adds _4 to the array
My development env: Windows 7, TortoiseHg, ASP.NET 4.0/MVC3 Test branch: code on test server
Env: Visual Studio Warning Level is set to 4, Code in the only file
dev env: Ubuntu 10.10 (32-bit), Eclipse, OpenJDK I currently have code for an executable
In my env I require 3.0.3 but when I script/server I get this: can't
I have an env var that's being set(PYTHONPATH) whenever I open a new Bash

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.