in reply to Re: Interacting with the shell ( backticks, system(), open -| )
in thread Interacting with the shell ( backticks, system(), open -| )
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Interacting with the shell ( backticks, system(), open -| )
by choroba (Cardinal) on Feb 05, 2014 at 15:01 UTC | |
|
Re^3: Interacting with the shell ( backticks, system(), open -| )
by Corion (Patriarch) on Feb 05, 2014 at 15:02 UTC |