문제

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.

도움이 되었습니까?

해결책

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

다른 팁

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
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top