08-10-2010
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
A shell in crontab per 5 min write a file
B shell in crontab per 6 min read a file
how to lock the share file a ;avioid confilict in write and read?
Thx : -) (1 Reply)
Discussion started by: zz_xm
1 Replies
2. Shell Programming and Scripting
Hi folks,
In our product installation program we edit xml files by deleting lines and appending new lines instead of them.
For example:
update_Log4plsql_xml()
{
machineName=`uname -n`
hostIP=`cat /etc/hosts | grep ${machineName} | cut -f1`
trap 'clean_up | tee -a $installLog ; exit' 1 2... (0 Replies)
Discussion started by: nir_s
0 Replies
3. Linux
Well Acording to my job...
Anyhelp plz.
I need some basic scripting stuff. (3 Replies)
Discussion started by: Irish Jimmy
3 Replies
4. Programming
Hello
I need to translade the power of unix command shell (grep, sed, awk, wc, etc..) to windows.
In my work every day I administrate 15 unix server ans 18 windows server, and I have the problem the absolutly limitation of windows shell. I´m a system administrator but I know programming.
I... (2 Replies)
Discussion started by: dalmus
2 Replies
5. Shell Programming and Scripting
Hi...
i need to write a shell script wich shows the full name and
station of every logged user in the system.
pls help! (1 Reply)
Discussion started by: relu89
1 Replies
6. Shell Programming and Scripting
I'm working on a program in with shell programming and it needs to be able to delete the contents of files in the Home directory on certain days of the week.(like tuesday). Can anyone help me with this?
Thanks in advance, Taffy. (7 Replies)
Discussion started by: Taffy
7 Replies
7. Shell Programming and Scripting
How would you make sure that a shell script (or a portion thereof) does not run (it waits or it terminates with error) when another instance of it is already running? (11 Replies)
Discussion started by: colemar
11 Replies
8. Shell Programming and Scripting
I have been asked to create a shell script that accepts a number of SQL select queries as input, runs them in sequence, spools the output to an EXCEL workbook, where, each worksheet is an output of a Select statement run above.
The workbook should be in a .XLS format. If a particular select... (2 Replies)
Discussion started by: ShellNovice1
2 Replies
9. Homework & Coursework Questions
1. The problem statement, all variables and given/known data:
Write a Shell script to automatically check that a specified user is logged in to the computer.
The program should allow the person running the script to specify the name of the user to be checked, the frequency in seconds at... (5 Replies)
Discussion started by: operator
5 Replies
10. Shell Programming and Scripting
Hi,
I am facing one issue.I am working on one script where I want to implement one check
PSS/TFM/Coupon/trunk/CouponProject/CouponService/src/test/java/com/travelport/service/pss/coupon/validator/CouponValidationReqValidatorTest.java
Now my problem is or requirement is if the above... (1 Reply)
Discussion started by: anuragpgtgerman
1 Replies
LEARN ABOUT OSX
moose::cookbook::roles::applicationtoinstance
Moose::Cookbook::Roles::ApplicationToInstance(3) User Contributed Perl Documentation Moose::Cookbook::Roles::ApplicationToInstance(3)
NAME
Moose::Cookbook::Roles::ApplicationToInstance - Applying a role to an object instance
VERSION
version 2.0604
SYNOPSIS
package MyApp::Role::Job::Manager;
use List::Util qw( first );
use Moose::Role;
has 'employees' => (
is => 'rw',
isa => 'ArrayRef[Employee]',
);
sub assign_work {
my $self = shift;
my $work = shift;
my $employee = first { !$_->has_work } @{ $self->employees };
die 'All my employees have work to do!' unless $employee;
$employee->work($work);
}
package main;
my $lisa = Employee->new( name => 'Lisa' );
MyApp::Role::Job::Manager->meta->apply($lisa);
my $homer = Employee->new( name => 'Homer' );
my $bart = Employee->new( name => 'Bart' );
my $marge = Employee->new( name => 'Marge' );
$lisa->employees( [ $homer, $bart, $marge ] );
$lisa->assign_work('mow the lawn');
DESCRIPTION
In this recipe, we show how a role can be applied to an object. In this specific case, we are giving an employee managerial
responsibilities.
Applying a role to an object is simple. The Moose::Meta::Role object provides an "apply" method. This method will do the right thing when
given an object instance.
MyApp::Role::Job::Manager->meta->apply($lisa);
We could also use the "apply_all_roles" function from Moose::Util.
apply_all_roles( $person, MyApp::Role::Job::Manager->meta );
The main advantage of using "apply_all_roles" is that it can be used to apply more than one role at a time.
We could also pass parameters to the role we're applying:
MyApp::Role::Job::Manager->meta->apply(
$lisa,
-alias => { assign_work => 'get_off_your_lazy_behind' },
);
We saw examples of how method exclusion and alias working in Moose::Cookbook::Roles::Restartable_AdvancedComposition.
CONCLUSION
Applying a role to an object instance is a useful tool for adding behavior to existing objects. In our example, it is effective used to
model a promotion.
It can also be useful as a sort of controlled monkey-patching for existing code, particularly non-Moose code. For example, you could create
a debugging role and apply it to an object at runtime.
AUTHOR
Moose is maintained by the Moose Cabal, along with the help of many contributors. See "CABAL" in Moose and "CONTRIBUTORS" in Moose for
details.
COPYRIGHT AND LICENSE
This software is copyright (c) 2012 by Infinity Interactive, Inc..
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.16.2 2012-09-19 Moose::Cookbook::Roles::ApplicationToInstance(3)