Sponsored Content
Top Forums Programming Perl - how to put to the next line if I have same pattern in one line Post 302543278 by askari on Saturday 30th of July 2011 01:30:46 PM
Old 07-30-2011
Hi Yazu,

Thank you so much.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl onliner to search the last line with an occurence of a pattern

Hi I need a perl onliner which seaches a line starting with a pattern(last occurence) and display it. similar to grep 'pattern' filename | tail -1 in UNIX Ex: I want to display the line starting with "cool" and which is a last occurence adadfadafadf adfadadf cool dfadfadfadfara... (4 Replies)
Discussion started by: ammu
4 Replies

2. UNIX for Dummies Questions & Answers

find pattern delete line with pattern and line above and line below

I have a file that will sometimes contain a pattern. The pattern is this: W/D FRM CHK 00 I want to find any lines with this pattern, delete those lines, and also delete the line above and the line below. (1 Reply)
Discussion started by: nickg
1 Replies

3. Shell Programming and Scripting

find pattern, delete line with pattern and line above and line below

I have a file that will sometimes contain a pattern. The pattern is this: FRM CHK 0000 I want to find any lines with this pattern, delete those lines, and also delete the line above and the line below. (4 Replies)
Discussion started by: nickg
4 Replies

4. Shell Programming and Scripting

Perl line count if it matches a pattern

#!/usr/bin/perl use Shell; open THEFILE, "C:\galileo_integration.txt" || die "Couldnt open the file!"; @wholeThing = <THEFILE>; close THEFILE; foreach $line (@wholeThing){ if ($line =~ m/\\0$/){ @nextThing = $line; if ($line =~ s/\\0/\\LATEST/g){ @otherThing =... (2 Replies)
Discussion started by: nmattam
2 Replies

5. Shell Programming and Scripting

search more than one pattern with perl on same line

Hi friends, I want to search for some hex error codes in some files. After the hex error code is found, the occurences would be counted. Afterwards the found hex errorcode would be cat into a separate file. Here is my code: #!/usr/bin/perl use File::Basename; my $find = $ARGV; my... (2 Replies)
Discussion started by: sdohn
2 Replies

6. Shell Programming and Scripting

Remove line based on string and put new line with parameter

Hi Folks, I am new to ksh, i have informatica parameter file that i need to update everyday with shell script. i need your help updating this file with new parameters. sample data $$TABLE1_DATE=04-27-2011 $$TABLE2_DATE=04-23-2011 $$TABLE3_DATE=03-19-2011 .......Highligned... (4 Replies)
Discussion started by: victor369
4 Replies

7. Shell Programming and Scripting

Grep the word from pattern line and update in subsequent lines till next pattern line reached

Hi, I have got the below requirement. please suggest. I have a file like, Processing Item is: /data/ing/cfg2/abc.txt /data/ing/cfg3/bgc.txt Processing Item is: /data/cmd/for2/ght.txt /data/kernal/config.klgt.txt I want to process the above file to get the output file like, ... (5 Replies)
Discussion started by: rbalaj16
5 Replies

8. Shell Programming and Scripting

Perl removing line match with pattern in column

Hi, I have log like this: ... (1 Reply)
Discussion started by: justbow
1 Replies

9. Shell Programming and Scripting

awk to combine lines from line with pattern match to a line that ends in a pattern

I am trying to combine lines with these conditions: 1. First line starts with text of "libname VALUE db2 datasrc" where VALUE can be any text. 2. If condition1 is met then continue to combine lines through a line that ends with a semicolon. 3. Ignore case when matching patterns and remove any... (5 Replies)
Discussion started by: Wes Kem
5 Replies

10. UNIX for Beginners Questions & Answers

Get an output of lines in pattern 1st line then 10th line then 11th line then 20th line and so on.

Input file: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 (6 Replies)
Discussion started by: Sagar Singh
6 Replies
Data::Section(3pm)					User Contributed Perl Documentation					Data::Section(3pm)

NAME
Data::Section - read multiple hunks of data out of your DATA section VERSION
version 0.101621 SYNOPSIS
package Letter::Resignation; use Data::Section -setup; sub quit { my ($class, $angry, %arg) = @_; my $template = $self->section_data( ($angry ? "angry_" : "professional_") . "letter" ); return fill_in($$template, \%arg); } __DATA__ __[ angry_letter ]__ Dear jerks, I quit! -- {{ $name }} __[ professional_letter ]__ Dear {{ $boss }}, I quit, jerks! -- {{ $name }} DESCRIPTION
Data::Section provides an easy way to access multiple named chunks of line-oriented data in your module's DATA section. It was written to allow modules to store their own templates, but probably has other uses. WARNING
You will need to use "__DATA__" sections and not "__END__" sections. Yes, it matters. Who knew! EXPORTS
To get the methods exported by Data::Section, you must import like this: use Data::Section -setup; Optional arguments may be given to Data::Section like this: use Data::Section -setup => { ... }; Valid arguments are: inherit - if true, allow packages to inherit the data of the packages from which they inherit; default: true header_re - if given, changes the regex used to find section headers in the data section; it should leave the section name in $1 default_name - if given, allows the first section to has no header and set its name Three methods are exported by Data::Section: section_data my $string_ref = $pkg->section_data($name); This method returns a reference to a string containing the data from the name section, either in the invocant's "DATA" section or in that of one of its ancestors. (The ancestor must also derive from the class that imported Data::Section.) By default, named sections are delimited by lines that look like this: __[ name ]__ You can use as many underscores as you want, and the space around the name is optional. This pattern can be configured with the "header_re" option (see above). If present, a single leading "" is removed, so that sections can encode lines that look like section delimiters. When a line containing only "__END__" is reached, all processing of sections ends. section_data_names my @names = $pkg->section_data_names; This returns a list of all the names that will be recognized by the "section_data" method. merged_section_data my $data = $pkg->merged_section_data; This method returns a hashref containing all the data extracted from the package data for all the classes from which the invocant inherits -- as long as those classes also inherit from the package into which Data::Section was imported. In other words, given this inheritance tree: A B C / D ...if Data::Section was imported by A, then when D's "merged_section_data" is invoked, C's data section will not be considered. (This prevents the read position of C's data handle from being altered unexpectedly.) The keys in the returned hashref are the section names, and the values are references to the strings extracted from the data sections. merged_section_data_names my @names = $pkg->merged_section_data_names; This returns a list of all the names that will be recognized by the "merged_section_data" method. local_section_data my $data = $pkg->local_section_data; This method returns a hashref containing all the data extracted from the package on which the method was invoked. If called on an object, it will operate on the package into which the object was blessed. This method needs to be used carefull, because it's weird. It returns only the data for the package on which it was invoked. If the package on which it was invoked has no data sections, it returns an empty hashref. local_section_data_names my @names = $pkg->local_section_data_names; This returns a list of all the names that will be recognized by the "local_section_data" method. TIPS AND TRICKS
MooseX::Declare and namespace::autoclean The namespace::autoclean library automatically cleans foreign routines from a class, including those imported by Data::Section. MooseX::Declare does the same thing, and can also cause your "__DATA__" section to appear outside your class's package. These are easy to address. The Sub::Exporter::ForMethods library provides an installer that will cause installed methods to appear to come from the class and avoid autocleaning. Using an explicit "package" statement will keep the data section in the correct package. package Foo; use MooseX::Declare; class Foo { # Utility to tell Sub::Exporter modules to export methods. use Sub::Exporter::ForMethods qw( method_installer ); # method_installer returns a sub. use Data::Section { installer => method_installer }, -setup; method my_method { my $content_ref = $self->section_data('SectionA'); print $$content_ref; } } __DATA__ __[ SectionA ]__ Hello, world. SEE ALSO
Inline::Files does something that is at first look similar, but it works with source filters, and contains the warning: It is possible that this module may overwrite the source code in files that use it. To protect yourself against this possibility, you are strongly advised to use the -backup option described in "Safety first". Enough said. AUTHOR
Ricardo SIGNES <rjbs@cpan.org> COPYRIGHT AND LICENSE
This software is copyright (c) 2011 by Ricardo SIGNES. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. perl v5.12.3 2011-04-29 Data::Section(3pm)
All times are GMT -4. The time now is 04:31 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy