here's something to get you started
q. what's not in here?
1. when the search string is found, writing the next ten lines in the array
2. write the new file only if search string is found in the given file
I have a file which contains several lines. Sample content of the file is as below.
OK testmessage email<test@123>
NOK receivemessage email<123@test>
NOK receivemessage email(123@test123)
NOK receivemessage email<abc@test>
i would like to know by scripting will... (10 Replies)
Can someone tell me how I can do this?
e.g:
Say file1.txt contains:
today is monday
the 22 of
NOVEMBER
2010
and file2.txt contains:
the
11th
month
of
How do i replace the word NOVEMBER with (5 Replies)
if the first string matches then print the previous line and current line and also print the following lines if the other string search matches.
Input
------
TranTime 2012 10 12
The Record starts here
Accountnumber: 4632473431274
TxnCode 323
TranID 329473242834
ccsdkcnsdncskd... (7 Replies)
I need to search the file using strings "Request Type" , " Request Method" , "Response Type" and by using result set find the xml tags and convert into a single line?. below are the scenarios.
Cat test
Nov 10, 2012 5:17:53 AM
INFO: Request Type
Line 1.... (5 Replies)
Hi,
I am trying to remove lines once a string is found till another string is found including the start string and end string. I want to basically grab all the lines starting with color (closing bracket). PS: The line after the closing bracket for color could be anything (currently 'more').... (1 Reply)
I am having a text file which is having more than 200 lines.
EX:
001010122 12000 BIB 12000 11200 1200003
001010122 2000 AND 12000 11200 1200003
001010122 12000 KVB 12000 11200 1200003
In the above file i want to search for string KVB and add/replace... (1 Reply)
Dear All
I am having a text file which is having more than 200 lines.
EX:
001010122 12000 BIB 12000 11200 1200003
001010122 2000 AND 12000 11200 1200003
001010122 12000 KVB 12000 11200 1200003
In the above file i want to search for string KVB... (5 Replies)
Hi,
Need your help for this scripting issue I have. I am not really good at this, so seeking your help.
I have a file looking similar to this:
Hello, i am human and name=ABCD.
How are you?
Hello, i am human and name=PQRS.
I am good.
Hello, i am human and name=ABCD.
Good bye.
Hello, i... (12 Replies)
Hi Everyone,
I have a requirement in ksh where i have a set of files in a directory. I need to search each and every file if a particular string is present in the file, delete that line and replace that line with another string expression in the same file.
I am very new to unix. Kindly help... (10 Replies)
Discussion started by: Pradhikshan
10 Replies
LEARN ABOUT DEBIAN
io::async::protocol::stream
IO::Async::Protocol::Stream(3pm) User Contributed Perl Documentation IO::Async::Protocol::Stream(3pm)NAME
"IO::Async::Protocol::Stream" - base class for stream-based protocols
SYNOPSIS
Most likely this class will be subclassed to implement a particular network protocol.
package Net::Async::HelloWorld;
use strict;
use warnings;
use base qw( IO::Async::Protocol::Stream );
sub on_read
{
my $self = shift;
my ( $buffref, $eof ) = @_;
return 0 unless $$buffref =~ s/^(.*)
//;
my $line = $1;
if( $line =~ m/^HELLO (.*)/ ) {
my $name = $1;
$self->invoke_event( on_hello => $name );
}
return 1;
}
sub send_hello
{
my $self = shift;
my ( $name ) = @_;
$self->write( "HELLO $name
" );
}
This small example elides such details as error handling, which a real protocol implementation would be likely to contain.
DESCRIPTION
This subclass of IO::Async::Protocol is intended to stand as a base class for implementing stream-based protocols. It provides an interface
similar to IO::Async::Stream, primarily, a "write" method and an "on_read" event handler.
It contains an instance of an "IO::Async::Stream" object which it uses for actual communication, rather than being a subclass of it,
allowing a level of independence from the actual stream being used. For example, the stream may actually be an IO::Async::SSLStream to
allow the protocol to be used over SSL.
As with "IO::Async::Stream", it is required that by the time the protocol object is added to a Loop, that it either has an "on_read"
method, or has been configured with an "on_read" callback handler.
EVENTS
The following events are invoked, either using subclass methods or CODE references in parameters:
$ret = on_read $buffer, $eof
The "on_read" handler is invoked identically to "IO::Async::Stream".
on_closed
The "on_closed" handler is optional, but if provided, will be invoked after the stream is closed by either side (either because the
"close()" method has been invoked on it, or on an incoming EOF).
PARAMETERS
The following named parameters may be passed to "new" or "configure":
on_read => CODE
CODE reference for the "on_read" event.
handle => IO
A shortcut for the common case where the transport only needs to be a plain "IO::Async::Stream" object. If this argument is
provided without a "transport" object, a new "IO::Async::Stream" object will be built around the given IO handle, and used as the
transport.
METHODS
$protocol->write( $data )
Writes the given data by calling the "write" method on the contained transport stream.
$protocol->connect( %args )
Sets up a connection to a peer, and configures the underlying "transport" for the Protocol. Calls "IO::Async::Protocol" "connect" with
"socktype" set to "stream".
AUTHOR
Paul Evans <leonerd@leonerd.org.uk>
perl v5.14.2 2012-10-24 IO::Async::Protocol::Stream(3pm)