9 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi, I have a tab delimited text file like this one. I need to do a partial match of a particular cell and then replace matches with an empty cell. So here is a sample:
Smith FordMustang ChevroletCamaro
Miller FordFiesta
Jones KiaSorrento
Davis ChevroletCamaro
Johnson ToyotaHighlander
I... (4 Replies)
Discussion started by: mikey11415
4 Replies
2. Shell Programming and Scripting
I posted the incorrect files yesterday and apologize. I also modified the awk script but with no luck. There are two text files in the zip (name.txt and output.txt). I am trying to match $2 in name.txt with $1 in output.txt and if they match then $1 of name.txt is copied to $7 of output.txt. ... (7 Replies)
Discussion started by: cmccabe
7 Replies
3. Shell Programming and Scripting
I am connecting to another server through sftp. I am running one batch script to pull file from another server. sometimes i am receiving partial files. I am using below commands in batch script.
ls -ltr new.txt
mget new.txt
bye
The file is of 1 MB only.In most of the cases , i received... (6 Replies)
Discussion started by: srinath01
6 Replies
4. UNIX for Dummies Questions & Answers
Hi I have a question and hope I can get answer here. Thank you in advance.
I have two files:
file1:
aa X
bb Y
cc Z
file2:
cc A
bb B
dd C
aa D
bb E
If the 1st column match in both file1 and file2, the 2nd column in file2 will be replaced by the 2nd column in file1. If there is no... (2 Replies)
Discussion started by: yuejian
2 Replies
5. Shell Programming and Scripting
I have this in log file /var/log/maillog
XXX YYY ZZZ :15214 I=:25 AAA BBB CCC
I need awk/sed operation on this, so that it retrieves only the first IP.
cat /var/log/maillog | sed_operation
55.66.77.88 (2 Replies)
Discussion started by: anil510
2 Replies
6. Shell Programming and Scripting
I have a list of strings in file:
10 10 AAA
120 13 BBBBB
23 11 CCCCC
11 32 DDDDDD
I want to replace first column of the text such as: 10, 129, 23, 11 with 11, 22, 33, 44.
I can do line by line, but just not sure how to replace partial string without... (1 Reply)
Discussion started by: ford99
1 Replies
7. Shell Programming and Scripting
Hello, this is probably a simple request but I've been toying with it for a while.
I have a large list of devices and commands that were run with a script, now I have lines such as:
a-router-hostname-C#show ver
I want to print everything up to (and excluding) the # and everything after it... (3 Replies)
Discussion started by: ippy98
3 Replies
8. Shell Programming and Scripting
Hi there!
New user to UNIX scripting. Had a question I was stuck on.
I've been trying to make a script(for a larger project) that would search a file(lets say playerlist).
the file is already formatted into columns so it may look like
First name(1-10) Last Name(11-20) address (21-30)
... (23 Replies)
Discussion started by: Sagramor
23 Replies
9. Shell Programming and Scripting
Hi,
Need to delete line prior to (INSERT/UPDATE/DELETE). In case ' available, then keep that. Pls refet below details.
Input
======================
l_s := ' INSERT INTO TEST'
l_P PD := ' UPDATE INTO TEST'
l_D := ' DELETE INTO TEST'
This is test
Output... (4 Replies)
Discussion started by: saurabhbaisakhi
4 Replies
HTML::Mason::Plugin(3pm) User Contributed Perl Documentation HTML::Mason::Plugin(3pm)
NAME
HTML::Mason::Plugin - Plugin Base class for Mason
SYNOPIS
package MasonX::Plugin::Timer;
use base qw(HTML::Mason::Plugin);
use Time::HiRes;
sub start_component_hook {
my ($self, $context) = @_;
push @{$self->{ timers }}, Time::HiRes::time;
}
sub end_component_hook {
my ($self, $context) = @_;
my $elapsed = Time::HiRes::time - pop @{$self->{ timers }};
printf STDERR "Component '%s' took %.1f seconds
",
$context->comp->title, $elapsed;
}
1;
DESCRIPTION
Use a Mason plugin to have actions occur at the beginning or end of requests or components. Plugins are activated by passing plugins in the
interpreter or request object. Each plugin in the list can be specified as a class name (in which case the plugin object is created once
for each request) or as an actual object of the plugin class.
If your plugin can be configured, place the configuration in class variables - for example,
$MasonX::Plugin::Timer::Units = 'seconds';
These can be set either from httpd.conf via PerlSetVar directives, or in perl directly from a handler.pl file.
PLUGIN HOOKS
A plugin class defines one or more of the following hooks (methods): start_request_hook, end_request_hook, start_component_hook, and
end_component_hook.
Every hook receives two arguments: the plugin object itself, and a context object with various methods.
start_request_hook
"start_request_hook" is called before the Mason request begins execution. Its context has the following read-only methods:
request # the current request ($m)
args # arguments the request was called with
When called in scalar context, args returns a list reference which may be modified to change or add to the arguments passed to the
first component. When called in list context, args returns a list (which may be assigned to a hash).
Note that subrequests (see HTML::Mason::Request will create a new plugin object and execute this code again; you can skip your code for
subrequests by checking "is_subrequest" on request. e.g.
sub start_request_hook {
my ($self, $context) = @_;
unless ($context->request->is_subrequest()) {
# perform hook action
}
}
Currently, this hook is called before any information about the requested component is available, so you cannot call methods like
"base_comp()" or "request_args()" on the Request object.
end_request_hook
"end_request_hook" is called before the Mason request exits. Its context has the following read-only methods:
request # the current request ($m)
args # arguments the request was called with
output # reference to the contents of the output buffer
wantarray # value of wantarray the request was called with
result # arrayref of value(s) that the request is about to return
error # reference to error, if any, that the request is about to throw
When called in scalar context, args returns a list reference; when called in list context, it returns a list (which may be assigned to
a hash).
result always contains an array ref; if wantarray is 0, the return value is the the first element of that array. The plugin may modify
output to affect what the request outputs, and result and error to affect what the request returns.
start_component_hook
"start_component_hook" is called before a component begins executing. Its context has the following read-only methods:
request # the current request ($m)
comp # the component object
args # arrayref of arguments the component was called with
The plugin may NOT modify args currently.
end_component_hook
"end_component_hook()" is called after a component has completed. Its context has the following read-only methods:
request # the current request ($m)
comp # the component object
args # arrayref of arguments the component was called with
wantarray # value of wantarray the component was called with
result # arrayref of value(s) that the component is about to return
error # reference to error, if any, that the component is about to throw
result always contains an array ref; if wantarray is 0, the return value is the first element of that array. The plugin may modify
both result and error to affect how the request returns.
It would be desirable for this hook to have access to the component's output as well as its return value, but this is currently
impossible because output from multiple components combine into a single buffer.
WARNINGS
Do not keep an unweakened reference to a request or component object in your plugin object, or you will create a nasty circular reference.
AUTHORS
Doug Treder, Jonathan Swartz, Dave Rolsky
SEE ALSO
HTML::Mason::Interp, HTML::Mason::Request
perl v5.14.2 2012-02-04 HTML::Mason::Plugin(3pm)