Re: UNIX 'command' equivalents in Perl
by TStanley (Canon) on Jul 17, 2007 at 17:19 UTC
|
| [reply] [Watch: Dir/Any] |
Re: UNIX 'command' equivalents in Perl
by derby (Abbot) on Jul 17, 2007 at 13:40 UTC
|
| [reply] [Watch: Dir/Any] |
|
You could go even further and take a look at Perl Power Tools.
Well, ppt used to be cool, but the project seems to be sleeping now... and anyway the purpose here is not to show how to reimplement possibly complex *NIX commands in Perl, but just the reverse: to show how things a newbie may want to system (or similar) out to an external program to do can be handled just fine with basic perl construct or judicious use of a core or CPAN module.
| [reply] [Watch: Dir/Any] |
Re: UNIX 'command' equivalents in Perl
by RMGir (Prior) on Jul 18, 2007 at 09:58 UTC
|
UNIX | Perl | Origin |
cut | split | built-in |
if | if, unless | built-in |
while | while, for, foreach | built-in |
Of course, cut usually winds up being in a complex pipe with
sed, sort, and join, so if you see cut in a pipe sequence,
odds are you've found a perfect piece of shell script to convert to perl...
And complex conditional or looping structures are much easier in perl than shell (at least to me...)
| [reply] [Watch: Dir/Any] |
Re: UNIX 'command' equivalents in Perl
by quester (Vicar) on Jul 18, 2007 at 07:09 UTC
|
You might also toss in:
expect Expect
and just possibly ssh...
ssh Net::SSH::Perl
if you think the target audience for this document won't be utterly terrorized by the Net::SSH::Perl installation. | [reply] [Watch: Dir/Any] |
Re: UNIX 'command' equivalents in Perl
by Trizor (Pilgrim) on Jul 18, 2007 at 04:29 UTC
|
You might also want to mention a2p and s2p for sed and awk replacements... | [reply] [Watch: Dir/Any] |
Re: UNIX 'command' equivalents in Perl
by jplindstrom (Monsignor) on Jul 18, 2007 at 15:03 UTC
|
| [reply] [Watch: Dir/Any] |
Re: UNIX 'command' equivalents in Perl
by eyepopslikeamosquito (Archbishop) on Jul 20, 2007 at 22:56 UTC
|
For the touch command, suggest you add utime in addition to open/close, since if the file already exists you don't need to open and close it, you can simply call the utime built-in function to change its access and modification times.
| [reply] [Watch: Dir/Any] |
|
use Shell::Command;
touch @files;
rm_f @files;
| [reply] [Watch: Dir/Any] [d/l] |
Re: UNIX 'command' equivalents in Perl
by Nasrudin (Acolyte) on Nov 14, 2007 at 23:37 UTC
|
I notice "ps" is missing...any suggestions? Proc::ProcessTable was the best I was able to find in an admittedly short search effort. | [reply] [Watch: Dir/Any] [d/l] |
Re: UNIX 'command' equivalents in Perl
by paulchernoch (Acolyte) on Aug 05, 2009 at 13:29 UTC
|
The 'which' command is simulated by using the function "which" in the module File::Which. | [reply] [Watch: Dir/Any] |