GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Psh::Strategy(3) User Contributed Perl Documentation Psh::Strategy(3)

Psh::Strategy - a Perl Shell Evaluation Strategy (base class)

  use Psh::Strategy;

Psh::Strategy offers a procedural strategy list interface and a base class for developing strategies.

  Psh::Strategy::list()

Returns a list of active Psh::Strategy objects.

  my $obj= Psh::Strategy::get('name')

Loads and initializes a certain Psh::Strategy object

  Psh::Strategy::add($obj [, $suggest_position])

Adds a strategy object to the list of active strategies

  Psh::Strategy::remove($name)

Removes a strategy

  @list= Psh::Strategy::available_list()

Lists available strategies

  my $pos= find($name)

Finds the position of the named strategy

  my $flag= active($name)

Returns true if the named strategy is currently active

You have to inherit from Psh::Strategy and you MUST at least override the functions "consumes", "applies", "execute". You CAN also override the function "runs_before"
  • consumes

    Returns either CONSUME_LINE, CONSUME_WORDS, CONSUME_TOKENS. CONSUME_LINE means you want to receive the whole input line unparsed. CONSUME_WORDS means you want to receive the whole input line tokenized (currenty unimplemented). CONSUME_TOKENS means that you want to receive a sub-part of the line, tokenized (this is probably what you want)

  • applies

    Returns undef if the strategy does not want to handle the input. Returns a human-readable description if it wants to handle the input.

    If you specified CONSUME_LINE, this method will be called as $obj->applies(\$inputline);

    If you specified CONSUME_TOKENS, this method will be called as $obj->applies(\$inputline,\@tokens,$piped_flag)

  • execute

    Will be called as $obj->execute(\$inputline,\@tokens,$how,$piped_flag)

    $how is what the call to applies returned. If @tokens is not applicable an empty array will be supplied.

    Your execute function should return an array of the form:

      ($evalcode, \@words, $forcefork, @return_val)
        

    If $evalcode, <@words> and <$forcefork> are undef, execution is finished after this call and @return_val will be used as return value.

    But $evalcode can also be a Perl sub - in which case it is evaluated later on, or a string - in which case it's a filename of a program to execute. @words will then be used as arguments for the program.

    $forcefork may be used to force a "fork()" call even for the perl subs.

  • runs_before

    Returns a list of names of other strategies. It is guaranteed that the evaluation strategy will be tried before those other named strategies are tried.

2007-07-06 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.