In the above file, some lines have empty field3. The requirement is to fill the missing field3 with the previous field3 value.
i.e. In line 3,4&5, field3 should have the value BusIntBatchMgr. In line 8, field3 should have the value Batch.
Please let me know how to achieve this in PERL, SED or AWK (any combination). Please give me the code. Thanks in advance.
Last edited by Franklin52; 01-02-2012 at 04:03 PM..
Reason: Please use code tags for data and code samples, thank you
Hi,
I would like to insert a file's filename into the first line of that file - for a batch of files. Is this possible using SED? Thanks in advance. (2 Replies)
Dear All,
I have the following input file. I want to replace data with null values.
I/P File:
9022334455|2008-12-06 06:10:21|2|Error@@@|esoo8erp|
9024334432|2008-12-06 08:40:59|6|Error@@@|6y2o8e6r|
O/P File:
9022334455||2||esoo8erp|
9024334432||6||6y2o8e6r|
... (4 Replies)
Hi
I have a file in the foll. format
*RECORD*
*FIELD NO*
.......
.......
*FIELD TX*
Data
*FIELD AV*
Data
*FIELD RF*
*RECORD*
*FIELD NO*
.......
.......
*FIELD TX*
Data
*FIELD RF* (4 Replies)
I'm attempting to insert multiple lines before a line matching a given search pattern. These lines are generated in a separate function and can either be piped in as stdout or read from a temporary file.
I've been able to insert the lines from a file after the pattern using:
sed -i '/pattern/... (2 Replies)
Greetings all,
I am trying to match a string, and after that insert a few lines above that match.
The string is "Version 1.0.0". I need to insert a few lines ONLY above the first match (there are many Version numbers in the file). The rest of the matches must be ignored. The lines I need to... (2 Replies)
Hi all,
I have two (2) sets of files that are based on some snapshots of database that I want to merge and insert any missing sequential number.
Below are example representation of these files:
file1:
DATE TIME COL1 COL2 COL3 COL4 ID
01/10/2013 0800 100 ... (3 Replies)
Hi All,
I am trying to insert two columns in the following text. I tried awk but failed to achieve. Highly appreciate your help
DATETIME="28-Sep-2013;20:09:08;"
CONTROL="AB"
echo "Myfile.txt;11671;7824.90;2822.48"
The DATETIME will be inserted at the beginning and CONTROL will... (4 Replies)
Hi Friends,
Below is my input file with "|" (pipe) as filed delimiter:
My Input File:
HDR|F1|F2||||F6|F7
I want to inser values in the record for field 4 and field 5.
Expected output
HDR|F1|F2||F4|F5|F6|F7
I am able to append the string to the end of the record, but not in between the... (3 Replies)
Using the file below, which will always have the first indicated by the digit after the -
and last id in it, indicated by the digit after the -, I am trying to use awk
to print the missing line or lines in file following the pattern of the previous line.
For example, in the file below the next... (4 Replies)
Discussion started by: cmccabe
4 Replies
LEARN ABOUT DEBIAN
moosex::emulate::class::accessor::fast
MooseX::Emulate::Class::Accessor::Fast(3pm) User Contributed Perl Documentation MooseX::Emulate::Class::Accessor::Fast(3pm)NAME
MooseX::Emulate::Class::Accessor::Fast - Emulate Class::Accessor::Fast behavior using Moose attributes
SYNOPSYS
package MyClass;
use Moose;
with 'MooseX::Emulate::Class::Accessor::Fast';
#fields with readers and writers
__PACKAGE__->mk_accessors(qw/field1 field2/);
#fields with readers only
__PACKAGE__->mk_ro_accessors(qw/field3 field4/);
#fields with writers only
__PACKAGE__->mk_wo_accessors(qw/field5 field6/);
DESCRIPTION
This module attempts to emulate the behavior of Class::Accessor::Fast as accurately as possible using the Moose attribute system. The
public API of "Class::Accessor::Fast" is wholly supported, but the private methods are not. If you are only using the public methods (as
you should) migration should be a matter of switching your "use base" line to a "with" line.
While I have attempted to emulate the behavior of Class::Accessor::Fast as closely as possible bugs may still be lurking in edge-cases.
BEHAVIOR
Simple documentation is provided here for your convenience, but for more thorough documentation please see Class::Accessor::Fast and
Class::Accessor.
A note about introspection
Please note that, at this time, the "is" flag attribute is not being set. To determine the "reader" and "writer" methods using
introspection in later versions of Class::MOP ( > 0.38) please use the "get_read_method" and "get_write_method" methods in
Class::MOP::Attribute. Example
# with Class::MOP <= 0.38
my $attr = $self->meta->find_attribute_by_name($field_name);
my $reader_method = $attr->reader || $attr->accessor;
my $writer_method = $attr->writer || $attr->accessor;
# with Class::MOP > 0.38
my $attr = $self->meta->find_attribute_by_name($field_name);
my $reader_method = $attr->get_read_method;
my $writer_method = $attr->get_write_method;
METHODS
BUILD $self %args
Change the default Moose class building to emulate the behavior of C::A::F and store arguments in the instance hashref.
mk_accessors @field_names
Create read-write accessors. An attribute named $field_name will be created. The name of the c<reader> and "writer" methods will be
determined by the return value of "accessor_name_for" and "mutator_name_for", which by default return the name passed unchanged. If the
accessor and mutator names are equal the "accessor" attribute will be passes to Moose, otherwise the "reader" and "writer" attributes will
be passed. Please see Class::MOP::Attribute for more information.
mk_ro_accessors @field_names
Create read-only accessors.
mk_ro_accessors @field_names
Create write-only accessors.
follow_best_practices
Preface readers with 'get_' and writers with 'set_'. See original Class::Accessor documentation for more information.
mutator_name_for
accessor_name_for
See original Class::Accessor documentation for more information.
set
See original Class::Accessor documentation for more information.
get
See original Class::Accessor documentation for more information.
meta
See Moose::Meta::Class.
SEE ALSO
Moose, Moose::Meta::Attribute, Class::Accessor, Class::Accessor::Fast, Class::MOP::Attribute, MooseX::Adopt::Class::Accessor::Fast
AUTHORS
Guillermo Roditi (groditi) <groditi@cpan.org>
With contributions from:
Tomas Doran (t0m) <bobtfish@bobtfish.net>
Florian Ragwitz (rafl) <rafl@debian.org>
LICENSE
You may distribute this code under the same terms as Perl itself.
perl v5.10.0 2009-09-15 MooseX::Emulate::Class::Accessor::Fast(3pm)