Class::Field(3pm) User Contributed Perl Documentation Class::Field(3pm)NAME
Class::Field - Class Field Accessor Generator
SYNOPSIS
package Thing;
use Class::Field qw'field const';
field 'this';
field 'list' => [];
field 'map' => {};
field 'that', -init => '$self->setup_that';
field 'circular_ref' => -weaken;
const 'answer' => 42;
DESCRIPTION
Class::Field exports two subroutines, "field" and "const". These functions are used to declare fields and constants in your class.
Class::Field generates custom code for each accessor that is optimized for speed.
FUNCTIONS
o field
Defines accessor methods for a field of your class:
package Example;
use base 'Parent';
use Class::Field qw'field const';
field 'foo';
field bar => [];
sub lalala {
my $self = shift;
$self->foo(42);
push @{$self->{bar}}, $self->foo;
}
The first parameter passed to "field" is the name of the attribute being defined. Accessors can be given an optional default value.
This value will be returned if no value for the field has been set in the object.
o const
const bar => 42;
The "const" function is similar to <field> except that it is immutable. It also does not store data in the object. You probably always
want to give a "const" a default value, otherwise the generated method will be somewhat useless.
NOTE
This code was taken directly out the Spiffy module for those people who just want this functionality without using the rest of Spiffy.
AUTHOR
Ingy dA~Xt Net <ingy@cpan.org>
COPYRIGHT
Copyright (c) 2006, 2008, 2009. Ingy dA~Xt Net.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
See <http://www.perl.com/perl/misc/Artistic.html>
perl v5.10.1 2009-12-10 Class::Field(3pm)
Check Out this Related Man Page
Validation::Class::Field(3pm) User Contributed Perl Documentation Validation::Class::Field(3pm)NAME
Validation::Class::Field - Field Object for Validation::Class Classes
VERSION
version 7.70
SYNOPSIS
package SomeClass;
use Validation::Class;
package main;
my $class = SomeClass->new;
...
my $field = $class->get_field('some_field_name');
$field->apply_filters;
$field->validate; # validate this only
$field->errors->count; # field-level errors
1;
DESCRIPTION
Validation::Class::Field is responsible for field data handling in Validation::Class derived classes, performs functions at the field-level
only.
This class automatically creates attributes for all acceptable field directives as listed under "DIRECTIVES" in
Validation::Class::Prototype.
ATTRIBUTES
errors
The errors attribute is a Validation::Class::Errors object.
METHODS
new
my $self = Validation::Class::Field->new({
name => 'some_field_name'
});
AUTHOR
Al Newkirk <anewkirk@ana.io>
COPYRIGHT AND LICENSE
This software is copyright (c) 2011 by Al Newkirk.
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.14.2 2012-06-28 Validation::Class::Field(3pm)
I have tab delimited file and need to remove all records prior to sort, that have non-numerics in the Field 2. valid/invalid field 2 data examples are:
" 123" valid
"1 23" invalid
" NOPE" invalid
I've tried this awk it does not recognize tab as the delimiter or check... (3 Replies)
This is my code:
#!/usr/bin/perl -w
use strict;
use Class::Struct;
struct App =>
{
name => '$',
};
sub App::name
{
my $self = shift;
if( @_ )
{
$self->{'name'} = shift;
}
return $self->{'name'}; (3 Replies)
letz say that my file has 7 records with only one field. So my file has:
11111111
000000000000000
1111
aaaabbbccc
1111111222000000
aaaaaaaa
zz
All i need is:
1. when the field has a repetition of the same instance(a-z or 0-9), i would consideer it to be invalid.... (4 Replies)
Guys,
I have a line like this: 109;201;1099010
and as you see that first field 109 and the last field starts with 109. I need to cut the rest in the last field after 109 which is 9010
How to do it? (2 Replies)
I'm trying to make this long line of codes in Perl looks nice by dividing it into 2 lines...
Before:
`echo "blahblahblahblahblahblahblahblahblahblahblah" > ~/lalala/lalala/lalala/lalala/lalala/abc`;
After:
`echo "blahblahblahblahblahblahblahblahblahblahblah" >
... (5 Replies)
Hi,
Thanks for keeping such a help-full platform active and live always.
I am new to this forum and to unix also.
Want to know how to count the repetition of a field in a file. Anything of awk, sed, perl, shell script, solution are welcomed.
Input File------------------
abc,12345
pqr,51223... (10 Replies)
Hi,
I have a file, fileA, that consists of two fields. Field 1 has an old object name, and field 2 has a new object name. I would like to search and replace a master file, FileB, by substituting the old object name (field 1 in fileA) with the new object name ( field 2 in fileA).
FileA:... (16 Replies)
hi
i have a file and its contents is as below:
8290804808
1338108313
1313141441
13131313133
1313131311
33424242242
23242424242
i want to print only those fields in bold. how to do it? (3 Replies)
Hi,
I have a flat file with fields separated by a X'1F'
i have to fetch 4th field from second line.
please help me how to achieve it.
I tried with below command and its not working.
cut -f4 -d`echo -e '\x1f'` filename.txt
I am using SunOS.
Thanks in advance. (2 Replies)
Hi,
I have a date/time field in my file. I have to search in all the records and append a timestamp to it, if the timestamp is missing in that field. Is there a possible awk solution for this?
Field date format
File1
====
1|vamu|payer|2007-12-02 02:01:30|bcbs|... (5 Replies)
Hi. I'd appreciate if I can get some direction in this issue to get me going.
Datafile1:
-About 4000 records, I have to update field#4 in selected records based on a match in the key field (Field#1).
-Field #1 is the key field (servername) . # of Fields may vary
# comment
server1 bbb ccc... (2 Replies)
I have a file with multiple fields, example below
File 1:
Field 1|Field 2|Field 3|Field 4|Field 5|Field 6|Field 7|100
Field 1|Field 2|Field 3|Field 4|Field 5|Field 6|Field 7|101
Field 1|Field 2|Field 3|Field 4|Field 5|Field 6|Field 7|102
Field 1|Field 2|Field 3|Field 4|Field 5|Field... (4 Replies)
I have text files, fields separated by commas, and there are 115 fields.
I need to use nawk to look at each line, if field $4==10, then count how many times the combination of field $5 and field $11 occur in the file.
I tried the following:
nawk -F, '{if($4==10){tg++;cd++,tgcd++}}END{for(i in... (3 Replies)
Hallo Team,
I have more than 2000 rows of data. The file is in a CSV format. Field 24 on my file is empty and i would like to populate field 24 with 10.10.11.31. Below is how one row looks like:
... (3 Replies)
Hi,
We need to produce a XML file based on a record/field delimited data file. At this point we could just script something out but I would like to ask the community what would be the best choice of programming language to do this, in terms of performance of execution, and in terms of complexity... (9 Replies)