0

When executing the following segment of code,

sub list {
    my($self)=@_;
    my $file = $self->{P_Dir}."/".$self->{Name};
    print `ls –l $file`;
}

I get this error:

ls: cannot access –l: No such file or directory

I am not really sure what is causing that, since if I manually type ls -l into the command line, I do not see that error.

fishpen0
  • 619
  • 1
  • 10
  • 23

2 Answers2

8

That that you've thankfully copy & pasted is a Unicode en dash character (U+2013) and not the ASCII hyphen character - (U+002D).

cjm
  • 61,471
  • 9
  • 126
  • 175
Moritz Bunkus
  • 11,592
  • 3
  • 37
  • 49
  • Yes, it seems somewhere copying between Windows and my Linux VM they changed. I should be more careful. Thanks! – fishpen0 Nov 09 '12 at 21:03
0

Hmmm... It works for me though:

$ cat test.pl 
#!/usr/bin/perl -w
use strict;
my $file = "rpm.pl";
print `ls -l $file`;

$ perl test.pl 
-rw-r--r-- 1 dheeraj dheeraj 922 2012-10-22 19:56 rpm.pl
slayedbylucifer
  • 22,878
  • 16
  • 94
  • 123