Sponsored Content
Top Forums Shell Programming and Scripting How to Compare two files depend on line length Chars Post 302248906 by elj3dah on Monday 20th of October 2008 05:17:46 AM
Old 10-20-2008
Dear,

Thanks for the help, but still this didn't help me Smilie
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

find 4 chars on 2nd line, 44 chars over

I know this should be simple, but I've been manning sed awk grep and find and am stupidly stumped :( I'm trying to use sed (or awk, find, etc) to find 4 characters on the second line of a file.txt 44-47 characters in. I can find lots of sed things for lines, but not characters. (4 Replies)
Discussion started by: unclecameron
4 Replies

2. Shell Programming and Scripting

compare line in two files

Dear All i want to compate two diff file line by line. Kindly help me. file 1: 1;givi;01012000;wer 2;sss;02012000;rrr 3;ccc;03012000;ttt file 2: 0;uuu;01012000;lll 1;givi;01012000;wer 2;sss;02012000;rrr 3;ccc;03012000;ttt 5;givi;01012000;hhh Output1: comman line to both file... (3 Replies)
Discussion started by: jaydeep_sadaria
3 Replies

3. Shell Programming and Scripting

Compare two text files line by line

Hi all I need help on comparing two texts files line by line and print the total number of lines matched. Any help is appreciated. Thanks in advance. (4 Replies)
Discussion started by: my_Perl
4 Replies

4. Shell Programming and Scripting

how compare first line of two files

Hi, Unix Gurus: I have a requirement which need to compare the first line of two files. e.g; file1 123 abc def file2 123 abcdef defe I need compare first line: in two file: in this case, two file contain same value in first line (123) anybody can help me. Thanks in advance (2 Replies)
Discussion started by: ken002
2 Replies

5. Shell Programming and Scripting

How to compare two files line by line

Using diff to compare 2 files FILE1: AAA AAA AAA AAA AAA AAA FILE2: BBB BBB AAA AAA BBB BBB diff FILE1 FILE2 (3 Replies)
Discussion started by: yannsun
3 Replies

6. Shell Programming and Scripting

how to read the contents of two files line by line and compare the line by line?

Hi All, I'm trying to figure out which are the trusted-ips and which are not using a script file.. I have a file named 'ip-list.txt' which contains some ip addresses and another file named 'trusted-ip-list.txt' which also contains some ip addresses. I want to read a line from... (4 Replies)
Discussion started by: mjavalkar
4 Replies

7. Shell Programming and Scripting

Check for length which exceeds specified length in a line

Hi, I have a issue, I need to loop through a comma delimited file and check for the length which exceeds specified length , if Yes truncate the string. But my problem is , I do not have to check for all the fields and the field lenght is not same for all the fields. For ex: Say my line... (9 Replies)
Discussion started by: rashmisb
9 Replies

8. Shell Programming and Scripting

Perl how to compare two pdf files line by line

Hi Experts, Would really appreciate if anyone can guide me how to compare two pdf files line by line and report the difference to another file. (3 Replies)
Discussion started by: prasanth_babu
3 Replies

9. Shell Programming and Scripting

Compare fields in two files line by line

I am new to awk scripting. I want to do a field by word (field) comparison of two files File1.txt and File2.txt. The files contain a list of | (pipe) separated field. **File 1: ------------------- aaa|bbb|ccc|eee|fff lll|mmm|nnn|ooo|ppp rrr|sss|ttt|uuu|vvv** File 2: ... (7 Replies)
Discussion started by: dhruvmohan
7 Replies

10. UNIX for Beginners Questions & Answers

Compare two files line by line in bash

Hello All! Thanks for taking time out and helping. My issue is, I have two files that have file names in it. Now, i need to go through each line of both the files and when the file names are different, i need to rename the file. Below is the example: File1</ fil1ename1.txt filename2,txt... (2 Replies)
Discussion started by: svks1985
2 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 01:23 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy