Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: system call vs. back quotes

by indapa (Monk)
on Jan 25, 2002 at 03:21 UTC ( #141371=note: print w/replies, xml ) Need Help??


in reply to system call vs. back quotes

A follow up question on this thread. Is it better to use backticks/system calls rather than a perl function. For example when renaming files is better to use perl's rename function, or a 'mv' command? Or another example, using unlink vs. rm.

Replies are listed 'Best First'.
(RhetTbull) Re: Re: system call vs. back quotes
by RhetTbull (Curate) on Jan 25, 2002 at 04:38 UTC
    I think it's almost always better to use the perl builtin or a module than a system call. First, it makes your code more portable. What if the script needs to be run on an OS without a "mv" command? Second, it's probably a bit easier to do error handling when calling a perlfunc than having to trap (and sometimes fiddle with) the return value of system. Given the plethora of great modules such as Archive::Tar, File::Copy, Compress::Zlib, Archive::Zip, etc. I find that I very rarely need to do a system call. There are times when you need to call an OS specific or some other 3rd party program but I find those times to be very rare.

    Whenever I find myself using system I always ask myself "Self, is there an all-perl way to do this?" It's saved me time more than once when I had to port the script to a different OS.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://141371]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2019-12-15 23:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?