Thanks for all kind answers.
I have another question that, though this is maybe hard, I want to
resize batch of images, from the large scale to small one, i.e, this image:
https://miscnote.net/wp-content/uploads/2018/07/lauren.jpg
(sorry but this is indeed me)
currently I use system() in perl to do the work:
system "convert lauren.jpg -resize 300x300 lauren.jpg"
But I think it's not good, since as you said, a shell is always being
called.
How to write it with pure perl way?
regards.
On 2018/7/24 星期二 PM 11:31, Uri Guttman wrote:
On 07/24/2018 08:35 AM, Lauren C. wrote:
Hi,
$ perl -le 'system "df -h"'
$ perl -le 'system "df","-h"'
The both two styles work fine.
what's the difference between them and which is better usage?
this is a more technical answer than the others but it may be useful to
you or other readers.
when you call system with one string argument, it then calls the shell
and passes that argument to the shell. the shell parses the string and
does globbing (expanding * and such). perl just gets the results back
from the shell and returns it.
if you call system with a list of arguments, it doesn't call the shell
but it forks a new process directly and passes it the list of arguments
in the standard way (argv style). so it is a more secure method as it
can't be fooled by shell tricks. it is also faster as it doesn't need to
fork a shell.
so both work in your example but they do very different methods of
getting there. in your case it likely won't matter (other than the full
path to the command issue someone posted).
uri
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/