0
#!/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?

3
  • 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. Apr 23, 2010 at 13:31
  • Seconded... ...
    – DVK
    Apr 23, 2010 at 13:50
  • It's a pretty clear question. I understand it just fine, and Nate gives the right answer. Apr 23, 2010 at 15:28

1 Answer 1

4

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".

2
  • Or, best of all, use FindBin to locate the script path ...
    – willert
    Apr 23, 2010 at 14:05
  • willert: No, don't use FindBin: perlmonks.org/?node_id=41213
    – Anonymous
    Apr 23, 2010 at 17:53

You must log in to answer this question.

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