Search code examples
perllsbackticks

Perl backticks: flags do not exist


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.


Solution

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