what should I use in perl /in place of grep -v in unix.
9 3555
Well, that depends. You could learn how to use Perl Regular Expressions and get really creative, or you could use back tics and use `grep -v`. (that is what I would probably do it I didn't have time to mess with the regex)
Regards,
Jeff
hi Jeff ..thanks a lot for ur quick response I have tried it but still having issues.
This is how i m using this system("zcat $file | grep -i TYPE=ERROR | `grep -v` BackendResponseException > /tmp/err.2wd")
getting following on running
sh: BackendResponseException: not found
Usage: grep -hblcnsviw pattern file . . .
can anyone please suggest sth on this
backticks are used in perl, but that string passed to the system command is a system level operation. Therefore don't use the backticks. -
system("zcat $file | grep -i TYPE=ERROR | grep -v BackendResponseException > /tmp/err.2wd")
-
Obviously try to get any system command to work at the command prompt first and then paste it into your perl code.
- Miller
backticks are used in perl, but that string passed to the system command is a system level operation. Therefore don't use the backticks.
Is that just a "best practices" thing? I ask only because the result should be the same, yes?
Regards,
Jeff
you should generally not use a function or operator that returns results, in a void context, like backtiks: - `command`; # backtiks used in void context
system() does not return results (it returns the exit value) from the program/application so is good for running commands that output results somewhere else, like a file. system() also does some "magical" things with the arguments passed to it. See the system() docs for details: perldoc system()
I'm sorry, I wasn't very clear.
All I meant to point out was that using backticks "inside" the system command was wrong. Using backticks instead of a system command would be just fine, and is in fact how the majority of coders I've observed tend to do such things.
- Miller
I'm sorry, I wasn't very clear.
All I meant to point out was that using backticks "inside" the system command was wrong. Using backticks instead of a system command would be just fine, and is in fact how the majority of coders I've observed tend to do such things.
- Miller
that was subtle, I missed it myself: system("zcat $file | grep -i TYPE=ERROR | `grep -v` BackendResponseException > /tmp/err.2wd")
backtiks, literally, in the system command
that was subtle, I missed it myself: system("zcat $file | grep -i TYPE=ERROR | `grep -v` BackendResponseException > /tmp/err.2wd")
backtiks, literally, in the system command
Oh, ok. I see now. I was curious because I knew that system returned a return code, but if you were doing something, system wise, that returned a value, then you almost HAVE to use backtics. (not to mention, if it was a bad practice, then I have been doing some very bad coding). :-)
Thanks for the clarification, both of you!!!
Regards,
Jeff
Kevin,
I sent you a PM.
Jeff
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Xah Lee |
last post by:
Just bumped into another irresponsibility in perl.
the crime in question this time is the module File::Basename.
Reproduction:
1. create a directory containing a file of this name:...
|
by: surfunbear |
last post by:
I've read some posts on Perl versus Python and studied a bit of my
Python book.
I'm a software engineer, familiar with C++ objected oriented
development, but have been using Perl because it is...
|
by: Al Belden |
last post by:
Hi all,
I've been working on a problem that I thought might be of interest: I'm
trying to replace some korn shell scripts that search source code files with
perl scripts to gain certain features...
|
by: Kirt Loki Dankmyer |
last post by:
So, I download the latest "stable" tar for perl (5.8.7) and try to compile
it on the Solaris 8 (SPARC) box that I administrate. I try all sorts of
different switches, but I can't get it to compile....
|
by: Xah Lee |
last post by:
Tabs versus Spaces in Source Code
Xah Lee, 2006-05-13
In coding a computer program, there's often the choices of tabs or
spaces for code indentation. There is a large amount of confusion about...
|
by: Ignoramus6539 |
last post by:
There were some strange requests to my server asking for config.php
file (which I do not have in the requested location).
I did some investigation. Seems to be a virus written in perl,...
|
by: js |
last post by:
Just my curiosity.
Can python beats perl at speed of grep-like processing?
$ wget http://www.gutenberg.org/files/7999/7999-h.zip
$ unzip 7999-h.zip
$ cd 7999-h
$ cat *.htm bigfile
$ du -h...
|
by: soniamadtha |
last post by:
hello everyone,
i have the following values : 98000345 and i would like to search this value in all of the sql files in the directory /temp/*sql
normally on unix its grep( ' 98000345 '...
|
by: happyse27 |
last post by:
Hi All,
I got this apache errors(see section A1 and A2 below) when I used a html(see section b below) to activate acctman.pl(see section c below). Section D below is part of the configuration...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |