10-10-2009
In Perl it is very simple to do.
But before i work for you, i would want to know what you have tried so far ?!
You should try, and ask for clarifications/advices if you have some difficulties -- which is always good to learn.
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
How can I extract few lines(like 10 to 15, top 10 and last 10) from a file using perl.
I do it with sed, head and tail in unix scripting. I am new to perl. Appreciate your help. (2 Replies)
Discussion started by: paruthiveeran
2 Replies
2. Shell Programming and Scripting
Hi,
I have a file and I want to sum all the numbers in it.
Example of the file:
0.6714359
-3842.59553830551
I used your forum (https://www.unix.com/shell-programming-scripting/74293-how-get-sum-all-lines-file.html) and found a script, what worked for me:
awk '{a+=$0}END{print a}'... (8 Replies)
Discussion started by: mario8eren
8 Replies
3. Shell Programming and Scripting
Hi Experts,
The question may look very silly by seeing the title, but please have a look at it clearly.
I have a text file where the first 5 columns in each row were supposed to be attributes of a sample(like sample name, number, status etc) and the next 25 columns are parameters on which... (3 Replies)
Discussion started by: ks_reddy
3 Replies
4. Shell Programming and Scripting
Hi,
I have a file with format
a b c d e
1 1 2 2 2
1 2 2 2 3
1 1 1 1 2
1 1 1 1 4
1 1 1 1 6
in column e i want to find all similar fields ( with perl script )and sum it how many are there
for instance in format above.
2 - 2 times
4 - 1 time
6 - 1 time
what i use is
... (14 Replies)
Discussion started by: Learnerabc
14 Replies
5. Shell Programming and Scripting
I am trying to print 1st, 2nd, 13th and 14th fields of a file of line numbers from 29 to 10029. I dont know how to put this in one code. Currently I am removing the selected lines by
awk 'NR==29,NR==10029' File1 > File2
and then doing
awk '{print $1, $2, $13, $14}' File2 > File3
Can... (3 Replies)
Discussion started by: ananyob
3 Replies
6. Shell Programming and Scripting
Hello,
I have attached one file named file.txt .
I have to create a file using the awk script with the records in which 38th position is P and not V .
ex
it should have
00501 HOLTSVILLE NYP00501
and it should not include
00501 I R S SERVICE CENTER ... (3 Replies)
Discussion started by: sonam273
3 Replies
7. Shell Programming and Scripting
Hi guys!
I'm new to scripting and I need to write a script in awk.
Here is example of file on which I'm working
ATOM 4688 HG1 PRO A 322 18.080 59.680 137.020 1.00 0.00
ATOM 4689 HG2 PRO A 322 18.850 61.220 137.010 1.00 0.00
ATOM 4690 CD ... (18 Replies)
Discussion started by: grincz
18 Replies
8. Shell Programming and Scripting
Hi friends,
This is sed & awk type question.
I have a text file which has numbers spread all over the file. I want to sum the series of numbers whenever i find it and produce an output file with the sum. For example
###start of input text file ####
abc
def
ghi
1
2
3
4
kjld
random... (3 Replies)
Discussion started by: kaaliakahn
3 Replies
9. UNIX for Dummies Questions & Answers
Hello,
I am new to Linux environment , I working on Linux script which should send auto email based on the specific condition from log file. Below is the sample log file
Name m/c usage
abc xxx 10
abc xxx 20
abc xxx 5
xyz ... (6 Replies)
Discussion started by: asjaiswal
6 Replies
10. Shell Programming and Scripting
I want to count the number of lines, I need this result be a number, and sum the last numeric column, I had done to make this one at time, but I need to make this for a crontab, so, it has to be an script, here is my lines:
It counts the number of lines:
egrep -i String file_name_201611* |... (5 Replies)
Discussion started by: Elly
5 Replies
LEARN ABOUT CENTOS
perl::critic::policy::variables::prohibitpunctuationvars
Perl::Critic::Policy::Variables::ProhibitPunctuationVarsUser Contributed Perl DocumentaPerl::Critic::Policy::Variables::ProhibitPunctuationVars(3)
NAME
Perl::Critic::Policy::Variables::ProhibitPunctuationVars - Write "$EVAL_ERROR" instead of "$@".
AFFILIATION
This Policy is part of the core Perl::Critic distribution.
DESCRIPTION
Perl's vocabulary of punctuation variables such as $!, $., and $^ are perhaps the leading cause of its reputation as inscrutable line
noise. The simple alternative is to use the English module to give them clear names.
$| = undef; #not ok
use English qw(-no_match_vars);
local $OUTPUT_AUTOFLUSH = undef; #ok
CONFIGURATION
The scratch variables $_ and @_ are very common and are pretty well understood, so they are exempt from this policy. The same goes for the
less-frequently-used default filehandle "_" used by stat(). All the regexp capture variables ($1, $2, ...) are exempt too. $] is exempt
because there is no English equivalent and Module::CoreList is based upon it.
You can add more exceptions to your configuration. In your perlcriticrc file, add a block like this:
[Variables::ProhibitPunctuationVars]
allow = $@ $!
The "allow" property should be a whitespace-delimited list of punctuation variables.
Other configuration options control the parsing of interpolated strings in the search for forbidden variables. They have no effect
on detecting punctuation variables outside of interpolated strings.
[Variables::ProhibitPunctuationVars]
string_mode = thorough
The option "string_mode" controls whether and how interpolated strings are searched for punctuation variables. Setting "string_mode =
thorough", the default, checks for special cases that may look like punctuation variables but aren't, for example $#foo, an array
index count; $$bar, a scalar dereference; or $::baz, a global symbol.
Setting "string_mode = disable" causes all interpolated strings to be ignored entirely.
Setting "string_mode = simple" uses a simple regular expression to find matches. In this mode, the magic variables $$, "$'", $# and $:
are ignored within interpolated strings due to the high risk of false positives. Simple mode is retained from an earlier draft of
the interpolated- strings code. Its use is only recommended as a workaround if bugs appear in thorough mode.
The "string_mode" option will go away when the parsing of interpolated strings is implemented in PPI. See "CAVEATS" below.
BUGS
Punctuation variables that confuse PPI's document parsing may not be detected correctly or at all, and may prevent detection of
subsequent ones. In particular, $" is known to cause difficulties in interpolated strings.
CAVEATS
ProhibitPunctuationVars relies exclusively on PPI to find punctuation variables in code, but does all the parsing itself for
interpolated strings. When, at some point, this functionality is transferred to PPI, ProhibitPunctuationVars will cease doing the
interpolating and the "string_mode" option will go away.
AUTHOR
Jeffrey Ryan Thalhammer <jeff@imaginative-software.com>
COPYRIGHT
Copyright (c) 2005-2011 Imaginative Software Systems. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of this license
can be found in the LICENSE file included with this module.
perl v5.16.3 2014-06-09 Perl::Critic::Policy::Variables::ProhibitPunctuationVars(3)