Re: System call doesn't work



xlue897@xxxxxxxxxx wrote:
Hi, All:


I have the following perl code intending to open several files using
vi. But it doesn't work.


ls test* | perl -n -e 'chomp; $cmd="vi $_"; unless(system($cmd))
{ print "success\n";}'

You're calling 'vi' with STDIN still connected to the pipe from 'ls'.

perl -le 'print system("vi $_") ? "error ".$?>>8 : "OK" for @ARGV' *.pl

-Joe
.