perl/unix: script in command line works but not in perl

so in unix this command works works and shows me a list of directories

find . -name \*.xls -exec dirname {} \; | sort -u | > list.txt
 

but when i try running a perl script to run this command

my $query = 'find . -name \*.xls -exec dirname {} \; | sort -u | > list.txt';
system($query);

list.txt is created but is blank with nothing there.

help?

Hi,

Remove pipe after sort.

my $query = 'find . -name \*.xls -exec dirname {} \; | sort -u | > list.txt';
system($query);
1 Like

thank you!