And it outputs the following (I deleted the userid column):#! /usr/bin/perl use strict; use warnings; my @files = system "find . -ls"; foreach my $file (@files) { chomp $file; print "$file\n"; }
Notice the trailing 0? If I replace my @files = system "find . -ls"; with my @files = `find . -ls`;, I get the same output, except the trailing 0 is missing.1105134059 2 drwxr-xr-x 3 .... users 2048 Feb 5 09:40 . 1105135378 1 -rw-r--r-- 1 .... users 506 Feb 3 10:54 ./t +est.pl 1105135090 1 -rw-r--r-- 1 .... users 93 Jan 24 15:41 ./c +alendar.pl 0
I understand why system() prints out the trailing 0 (it's the exit status of find()), but why is it also outputting everything find() outputs? I thought it should only return the exit status.
In reply to Re^2: Interacting with the shell ( backticks, system(), open -| )
by jktstance
in thread Interacting with the shell ( backticks, system(), open -| )
by jktstance
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |