In Perl you always end up making calls to the shell because it saves work. Why write a block of Perl code to do 'uname -r'?
You do not "call" a shell.
You must fork a new process, exec it, let it run, wait for it to finish, reap it, and then return to whatever else you were doing. That's what system() does -- just to create a shell. And then the shell, once running, must do so again, to run whatever external command you asked it to do.
So you are running a thing which runs a thing and must wait for it to quit before you can wait for it to quit.
...which it does, having run the single, individual command you fed into backticks or system().
Imagine running full instances of Perl every time you needed to call uname in BASH even though uname has nothing to do with perl. That's the degree of pointless waste that happens when you write external-command-intensive programs in perl. It can be almost cripplingly wasteful.
Just using the shell in the manner it was meant to be used in the first place avoids quite a lot of round trip. Or you could write code in perl to the same effect, except that perl is pretty bad at that...
Quote:
On the other hand, Perl lets you do things like "do something unless condition", or "if condition, etc" all in one statement.
That's a nice feature, isn't it?
sh had it first -- by decades.
Quote:
What would we shell coders do without Awk and Sed and Grep?
You have backpedaled miles from your argument that shell code is somehow "unsafe" while perl code running plethoras of individual short-lived shells is somehow not.
Anyway. Would you agree that running awk thousands of individual times to process tiny amounts of data is a suboptimal use of it?
Perl is good at some things. I enjoy it for some things. Code like the OP is not an effective use of it.
Last edited by Corona688; 12-21-2014 at 01:22 AM..
These 2 Users Gave Thanks to Corona688 For This Post:
I need help with a perl parsing script. I have some error logs on a windows machine that I need to parse from a text file, but I know nothing about perl. I usually run this bash script on my linux box and it does just what I need. How would I do the same thing with perl and port it to my windows... (2 Replies)
Hello Group,
I request your help with a shell script for filter an ascii file (this is small piece of the file):
09/24/2009,00:00,1.0268,1.0268,1.0249,1.0250,518
09/24/2009,01:00,1.0251,1.0261,1.0249,1.0259,424
09/24/2009,02:00,1.0258,1.0272,1.0258,1.0269,372... (3 Replies)
I have oracle 9i database installed with UTF-8 Encoding.
I want a perl script that converts unicode to utf8 before commiting in database and utf8 to unicode when retreiving from database
For example :
the word Ïntêrnatïônàlîzâtion has to be stored in database as Internationalization and when retreived... (6 Replies)
Can anyone provide me with a ksh or bash script which will accept a timestamp (format is YYYY-MM-DD-HH24.Mi.Ss) and time offset (in hours). The output will be (timestamp passed - time offset passed deducted from it) in the same YYYY-MM-DD-HH24.Mi.Ss format.
Basically I am trying to convert the... (1 Reply)
while converting batch file to shell script ...dis command is ther i dunno how to change...can anyone knws how to change into shell script
rm !(D:\temp\XX.txt) (3 Replies)
Please tell me how to convert below program from shell script to perl. Same commands need to use in shutdown, just need program help for startup.
export ORACLE_BASE=/home/oracle1
lsnrctl start lndb1
sqlplus '/ as sysdba'
startup; (2 Replies)
Hi All,
I have a small tool which is currently configured in batch scripts only. But my need is to run it on Linux platform, so I have been trying to convert a batch script to shell script.
below is the batch script:
@echo off
IF "%1"== "" GOTO ARGERR
REM UPDATE THESE PROPERTIES TO... (2 Replies)
Here is a powershell script to use restful API to create ticket in our ticketing tool. Can anyone please convert it to a shell script sothat, I can run it in Unix servers,
below is the code:
$body = @{
Customer= ''test'
Summary= 'test summary'
Impact= '4-Minor/Localized'
... (2 Replies)
Hi All,
I am trying to print all the packages info in solaris 11 using below script.
#!/usr/bin/env bash
pkginfo -l | egrep '(BASEDIR|NAME|VERSION)' | awk '{print}' > /tmp/cp1
/usr/bin/nawk -F: '
{for (i=1; i<=NF; i++) {gsub (/^ *| *$/, "", $i)
... (5 Replies)