Hi Friends
I have the following input data in 2 columns.
SNo 1
I1 Value
I2 Value
I3 Value
SNo 2
I4 Value
I5 Value
I6 Value
I7 Value
SNo 3
I8 Value
I9 Value
...............
................
SNo N (1 Reply)
Hi All,
I have to search in multiple columns for multiple values, if the match is found then print the values as below.
Eg:
cat t1
Z|VLD_AB_P|VLD_CD_P|VLD_EF_F|VLD_GH_F|100
Y|VLD_AB_F|VLD_CD_F|VLD_EF_P|VLD_GH_P|101
if then print "Invalid AB in $6"
if then print "Invalid CD in... (6 Replies)
Hi,
I have a tab-delimited file as follows:
1 1 2 2 3 3 4 4
a a b b c c d d
5 5 6 6 7 7 8 8
e e f f g g h h
9 9 10 10 11 11 12 12
i i j j k k l l
13 13 14 14 15 15 16 16
m m n n o o p p
The output I need is:
1 1 a a 5 5 e e 9 9 i i 13... (5 Replies)
Hello,
I would like to ask for help with csh script.
An example of an input in .txt file is below, the number of lines varies from file to file and I have 2 or 3 columns with values. I would like to read all the values (probably one by one) and set them to independent unique variables that... (7 Replies)
Hello Gurus,
I have a multiple pipe separated files which have records going over multiple Lines. End of line separator is \n and records going over multiple lines have <CR> as separator. below is example from one file.
1|ABC DEF|100|10
2|PQ
RS
T|200|20
3| UVWXYZ|300|30
4| GHIJKL|400|40... (7 Replies)
Hi all,
I have a data file. It contains one header line followed by a new line which is one row of different characters without separators (charahters can be dots, dash, capital and small letters). What I need is ignoring header line to transpose these characters so they form a column. So, from... (4 Replies)
Discussion started by: kush
4 Replies
LEARN ABOUT DEBIAN
poe::filter::map
POE::Filter::Map(3pm) User Contributed Perl Documentation POE::Filter::Map(3pm)NAME
POE::Filter::Map - transform input and/or output within a filter stack
SYNOPSIS
#!perl
use POE qw(
Wheel::FollowTail
Filter::Line Filter::Map Filter::Stackable
);
POE::Session->create(
inline_states => {
_start => sub {
my $parse_input_as_lines = POE::Filter::Line->new();
my $redact_some_lines = POE::Filter::Map->new(
Code => sub {
my $input = shift;
$input = "[REDACTED]" unless $input =~ /sudo[d+]/i;
return $input;
},
);
my $filter_stack = POE::Filter::Stackable->new(
Filters => [
$parse_input_as_lines, # first on get, last on put
$redact_some_lines, # first on put, last on get
]
);
$_[HEAP]{tailor} = POE::Wheel::FollowTail->new(
Filename => "/var/log/system.log",
InputEvent => "got_log_line",
Filter => $filter_stack,
);
},
got_log_line => sub {
print "Log: $_[ARG0]
";
}
}
);
POE::Kernel->run();
exit;
DESCRIPTION
POE::Filter::Map transforms data inside the filter stack. It may be used to transform input, output, or both depending on how it is
constructed. This filter is named and modeled after Perl's built-in map() function.
POE::Filter::Map is designed to be combined with other filters through POE::Filter::Stackable. In the "SYNOPSIS" example, a filter stack
is created to parse logs as lines and redact all entries that don't pertain to a sudo process.
PUBLIC FILTER METHODS
In addition to the usual POE::Filter methods, POE::Filter::Map also supports the following.
new
new() constructs a new POE::Filter::Map object. It must either be called with a single Code parameter, or both a Put and a Get parameter.
The values for Code, Put and Get are code references that, when invoked, return transformed versions of their sole parameters. A Code
function will be used for both input and output, while Get and Put functions allow input and output to be filtered in different ways.
# Decrypt rot13.
sub decrypt_rot13 {
my $encrypted = shift;
$encrypted =~ tr[a-zA-Z][n-za-mN-ZA-M];
return $encrypted;
}
# Encrypt rot13.
sub encrypt_rot13 {
my $plaintext = shift;
$plaintext =~ tr[a-zA-Z][n-za-mN-ZA-M];
return $plaintext;
}
# Decrypt rot13 on input, and encrypt it on output.
my $rot13_transcrypter = POE::Filter::Map->new(
Get => &decrypt_rot13,
Put => &encrypt_rot13,
);
Rot13 is symmetric, so the above example can be simplified to use a single Code function.
my $rot13_transcrypter = POE::Filter::Map->new(
Code => sub {
local $_ = shift;
tr[a-zA-Z][n-za-mN-ZA-M];
return $_;
}
);
modify
modify() changes a POE::Filter::Map object's behavior at run-time. It accepts the same parameters as new(), and it replaces the existing
transforms with new ones.
# Switch to "reverse" encryption for testing.
$rot13_transcrypter->modify(
Code => sub { return scalar reverse shift }
);
SEE ALSO
POE::Filter for more information about filters in general.
POE::Filter::Stackable for more details on stacking filters.
BUGS
None known.
AUTHORS & COPYRIGHTS
The Map filter was contributed by Dieter Pearcey. Documentation is provided by Rocco Caputo.
Please see the POE manpage for more information about authors and contributors.
perl v5.14.2 2012-05-15 POE::Filter::Map(3pm)