On 07/24/2018 09:56 PM, Lauren C. wrote:
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?


that's easy. just call system with a list of those tokens or words. all the shell does with that is break up the string on spaces. you can do it by hand yourself with qw() or call split ' ' on the whole string.

system qw( convert lauren.jpg -resize 300x300 lauren.jpg ) ;

my $cmd = 'convert lauren.jpg -resize 300x300 lauren.jpg' ;
system split ' ', $cmd ;

i used $cmd like that because sometimes you need to build up strings like that and i like to print them out for debugging to make sure i made the correct string.

you could also split the words to an array and pass that to system. TIMTOWTDI!!

uri

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to