---
name: "Bio::Tools::StateMachine::IOStateMachine"
section: "3pm"
platform: "linux"
package: "bioperl"
version: "1.0-1"
release: "Debian 3.0 (Woody)"
platforms: ["linux"]
url: "https://new.carta.tech/Bio::Tools::StateMachine::IOStateMachine"
---

# Bio::Tools::StateMachine::IOStateMachine(3pm)

Bio::Tools::StateMachine::IOStateMachine - IO-based implementation of AbstractStateMachine

```
    use Bio::Tools::IOStateMachine;
```

```
    # A state machine that reads input from a file
    my $sm = Bio::Tools::IOStateMachine->new( -file => 'data.txt' );
```

```
    # A state machine that reads input from a STDIN
    my $sm = Bio::Tools::IOStateMachine->new();
```

```
    # A state machine that reads input from a STDIN
    # and times out if input doesn't arrive within 30 seconds.
    my $sm = Bio::Tools::IOStateMachine->new( -timeout_sec => 30 );
```

An implementation of AbstractStateMachine that samples an input stream to determine whether a state change has occurred. To get a feel for how to use this, have look at Bio::SearchIO::psiblast which subclasses IOStateMachine.\
 **Mailing Lists** User feedback is an integral part of the evolution of this and other Bioperl modules.  Send your comments and suggestions preferably to one of the Bioperl mailing lists.  Your participation is much appreciated.

```
    bioperl-l@bioperl.org              - General discussion
    http://bio.perl.org/MailList.html  - About the mailing lists
```

**Reporting Bugs** Report bugs to the Bioperl bug tracking system to help us keep track the bugs and their resolution. Bug reports can be submitted via email or the web:

```
    bioperl-bugs@bio.perl.org
    http://bio.perl.org/bioperl-bugs/
```

Steve Chervitz, \<sac@bioperl.org\> See the FEEDBACK  section for where to send bug reports and comments. Copyright (c) 2001 Steve Chervitz. All Rights Reserved. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. This software is provided "as is" without warranty of any kind. The rest of the documentation details each of the object methods. Internal methods are usually preceded with a \_\
 *\_init\_state\_machine()*

```
 Argument : Named parameter -TIMEOUT_SEC => seconds,
            to specify the number of seconds to allow before throwing
            an exception if input fails to arrive within that amount of time.
```

*check\_for\_new\_state()*

```
 Purpose  : Obtains data from the input stream to be checked
            for the existence of a new state.
 Usage    : check_for_new_state( [$ignore_blank_lines] );
 Argument : boolean: true if you want to ignore blank lines
 Returns  : the next chunk of input ($/ is not altered)
            If there is no more input, returns undef.
```

Subclasses should override this method and call it to obtain the chunk of data for new state testing. \
 *next\_input\_chunk()*

```
 Argument : n/a
 Returns  : The next chunk of input data from the IO stream
            To be used in determining what state the machine should be in.
```
