Sponsored Content
Top Forums Shell Programming and Scripting script in perl for removing strings between a file Post 302566040 by durden_tyler on Wednesday 19th of October 2011 10:30:16 AM
Old 10-19-2011
Code:
$
$
$ cat f33
ATOM 2517 O   VAL 160 8.337  12.679  -2.487
ATOM 2518 OXT VAL 160 7.646  12.461  -0.386
TER
ATOM 2519 N   VAL 161 -14.431  5.789 -25.371
ATOM 2520 H1  VAL 161 -15.336  5.698 -25.811
ATOM 2521 H2  VAL 161 -13.416 10.529  17.708
ATOM 2522 H3  VAL 161 -14.363  9.436  18.498
ATOM 2523 CA  VAL 161   4.400  9.233  16.454
ATOM 2524 HA  VAL 161   3.390  9.170  16.047
$
$
$
$ perl -lne 'if (/^TER/) {$i++}
             elsif (defined $i and $i<6) {$i++; print if $i==2}
             else {print $prev};
             $prev=$_;
             END {print $prev}' f33
 
ATOM 2517 O   VAL 160 8.337  12.679  -2.487
ATOM 2519 N   VAL 161 -14.431  5.789 -25.371
ATOM 2523 CA  VAL 161   4.400  9.233  16.454
ATOM 2524 HA  VAL 161   3.390  9.170  16.047
$
$
$

tyler_durden
This User Gave Thanks to durden_tyler For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

perl question - removing line from input file

In perl I want to do remove the top line of my input file then process the next line. I want to do something like head -1 inputfile > temp grep -v temp inputfile > newinputfile cp newinputfile inputfle is this possible in perl? (3 Replies)
Discussion started by: reggiej
3 Replies

2. Shell Programming and Scripting

ideas for perl script - strings,conditionals..etc

I have a matrix , how do I compare all the elements of a column , lets say I want to check if the columns contain the alphabets "S","H","A","R","A","T". and not "X"s. Lets say matrix looks something like this .. SSSXSH HHXXHA AAXXAT RRRXRS AAXTAR TTTTTA I can hard code it where... (4 Replies)
Discussion started by: sharatz83
4 Replies

3. UNIX for Dummies Questions & Answers

Help removing strings from one file that match any of the values in a second file.

Hello, I have a file that lists a few hundred values. Example: abca abcb abcc abcd I have a 2nd file with a few thousand lines. I need to remove every line from the 2nd file that contains any of the values listed in first file. Example of strings to delete: line1 *abca* end of... (1 Reply)
Discussion started by: upstate_boy
1 Replies

4. Shell Programming and Scripting

Can we pass an array of strings from a Perl Program to a Shell Script?

Hi Folks, The subject is my question: Can we pass an array of strings from a Perl Program to a Shell Script? Please provide some sample code. Thanks ---------- Post updated at 11:52 PM ---------- Previous update was at 11:43 PM ---------- I got it. Its here:... (0 Replies)
Discussion started by: som.nitk
0 Replies

5. Shell Programming and Scripting

Perl removing strings from a variable value

Dear all, I have a variable called $abc, which the value is something like below, *** *********** : ***** where * can be anything. I need to remove all but the final characters until last whitespace. example grd groupstudy : tutor6/7 becomes tutor6/7 something like if... (2 Replies)
Discussion started by: tententen
2 Replies

6. Shell Programming and Scripting

Replacing strings in perl script

HI all, These are examples of the original value from a variable $abc can be FastEthernet1/0 GigabitEthernet3/1 Serial1/0 If $abc is FastEthernet*/* (where * can be any number), replace $abc value to fa*/* (same number as the original value). GigabitEthernet becomes ga*/* and Serial... (2 Replies)
Discussion started by: tententen
2 Replies

7. Shell Programming and Scripting

Perl script to delimit size of strings

Hello, I have a huge file of over 2,00,00,00 strings in UTF8 format. I have managed to write a script in Perl which sorts them neatly as per their Unicode ranges. However I am now stuck with a script which will pipe out all strings between 3 and 20 letters/characters. I am not very good at... (2 Replies)
Discussion started by: gimley
2 Replies

8. Shell Programming and Scripting

PERL "filtering the log file removing the duplicates

Hi folks, I have a log file in the below format and trying to get the output of the unique ones based on mnemonic IN PERL. Could any one please let me know with the code and the logic ? Severity Mnemonic Log Message 7 CLI_SCHEDULER Logfile for scheduled CLI... (3 Replies)
Discussion started by: scriptscript
3 Replies

9. Programming

Perl script to merge cells in column1 which has same strings, for all sheets in a excel workbook

Perl script to merge cells ---------- Post updated at 12:59 AM ---------- Previous update was at 12:54 AM ---------- I am using below code to read files from a dir and print to excel. open(my $in, '<', $file) or die "Could not open file: $!"; my $rowCount = 0; my $colCount = 0;... (11 Replies)
Discussion started by: Jack_Bruce
11 Replies

10. Shell Programming and Scripting

Perl script to find process and exclude strings from the output

Hi team, I'm a newbie of Perl Script and looking to create a simple perl script that will run in the Linux system: 1) to find process, such as ps -ef | grep process name 2) to exclude strings from the output if it found, for instance if i see abc from usr process, then will exclude it from... (1 Reply)
Discussion started by: hoffman2503
1 Replies
CPANPLUS::Configure(3perl)				 Perl Programmers Reference Guide				CPANPLUS::Configure(3perl)

NAME
CPANPLUS::Configure - configuration for CPANPLUS SYNOPSIS
$conf = CPANPLUS::Configure->new( ); $bool = $conf->can_save; $bool = $conf->save( $where ); @opts = $conf->options( $type ); $make = $conf->get_program('make'); $verbose = $conf->set_conf( verbose => 1 ); DESCRIPTION
This module deals with all the configuration issues for CPANPLUS. Users can use objects created by this module to alter the behaviour of CPANPLUS. Please refer to the "CPANPLUS::Backend" documentation on how to obtain a "CPANPLUS::Configure" object. METHODS
$Configure = CPANPLUS::Configure->new( load_configs => BOOL ) This method returns a new object. Normal users will never need to invoke the "new" method, but instead retrieve the desired object via a method call on a "CPANPLUS::Backend" object. load_configs Controls whether or not additional user configurations are to be loaded or not. Defaults to "true". $bool = $Configure->init( [rescan => BOOL]) Initialize the configure with other config files than just the default 'CPANPLUS::Config'. Called from "new()" to load user/system configurations If the "rescan" option is provided, your disk will be examined again to see if there are new config files that could be read. Defaults to "false". Returns true on success, false on failure. can_save( [$config_location] ) Check if we can save the configuration to the specified file. If no file is provided, defaults to your personal config. Returns true if the file can be saved, false otherwise. $file = $conf->save( [$package_name] ) Saves the configuration to the package name you provided. If this package is not "CPANPLUS::Config::System", it will be saved in your ".cpanplus" directory, otherwise it will be attempted to be saved in the system wide directory. (On Debian systems, this system wide directory is /etc/perl.) If no argument is provided, it will default to your personal config. Returns the full path to the file if the config was saved, false otherwise. options( type => TYPE ) Returns a list of all valid config options given a specific type (like for example "conf" of "program") or false if the type does not exist ACCESSORS
Accessors that start with a "_" are marked private -- regular users should never need to use these. See the "CPANPLUS::Config" documentation for what items can be set and retrieved. get_SOMETHING( ITEM, [ITEM, ITEM, ... ] ); The "get_*" style accessors merely retrieves one or more desired config options. set_SOMETHING( ITEM => VAL, [ITEM => VAL, ITEM => VAL, ... ] ); The "set_*" style accessors set the current value for one or more config options and will return true upon success, false on failure. add_SOMETHING( ITEM => VAL, [ITEM => VAL, ITEM => VAL, ... ] ); The "add_*" style accessor adds a new key to a config key. Currently, the following accessors exist: set|get_conf Simple configuration directives like verbosity and favourite shell. set|get_program Location of helper programs. _set|_get_build Locations of where to put what files for CPANPLUS. _set|_get_source Locations and names of source files locally. _set|_get_mirror Locations and names of source files remotely. _set|_get_fetch Special settings pertaining to the fetching of files. BUG REPORTS
Please report bugs or other issues to <bug-cpanplus@rt.cpan.org<gt>. AUTHOR
This module by Jos Boumans <kane@cpan.org>. COPYRIGHT
The CPAN++ interface (of which this module is a part of) is copyright (c) 2001 - 2007, Jos Boumans <kane@cpan.org>. All rights reserved. This library is free software; you may redistribute and/or modify it under the same terms as Perl itself. SEE ALSO
CPANPLUS::Backend, CPANPLUS::Configure::Setup, CPANPLUS::Config perl v5.14.2 2014-09-29 CPANPLUS::Configure(3perl)
All times are GMT -4. The time now is 07:38 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy