Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top
#!/usr/bin/env perl
use warnings; 
use strict;
use XML::LibXML;

my $parser = XML::LibXML->new;
my $file = './example.xml';
my $doc = $parser->parse_file( $file );
print ref( $doc ), "\n";

When I move this script and the example.xml-file to /home/me/ then the script works. When I move the script and the example.xml-file to /home/me/bin/ then the script doesn't find the example.xml-file. Is this some special-feature of the bin-directory?

share|improve this question

migrated from stackoverflow.com Apr 24 '10 at 5:02

This question came from our site for professional and enthusiast programmers.

1  
This is not a programming question but a general computer user question about how executables are located by the shell. Voting to move to SU. – Sinan Ünür Apr 23 '10 at 13:31
    
Seconded... ... – DVK Apr 23 '10 at 13:50
    
It's a pretty clear question. I understand it just fine, and Nate gives the right answer. – brian d foy Apr 23 '10 at 15:28
up vote 4 down vote accepted

Nope. But, it'll be opening the file from "./example.xml", which should be your current working directory (cwd, in Unix parlance). It's probably getting your script from the command search path ($PATH environment variable).

Refer to it by absolute pathname, and it'll work fine. I'd also recommend reading up on cwd, pwd and "man pwd".

share|improve this answer
    
Or, best of all, use FindBin to locate the script path ... – willert Apr 23 '10 at 14:05
    
willert: No, don't use FindBin: perlmonks.org/?node_id=41213 – Anonymous Apr 23 '10 at 17:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .