# Copyright (C) 2001-2008, The Perl Foundation.
# $Id: /mirror/trunk/examples/pir/substr.pir 33793 2008-12-10T14:52:06.244557Z coke  $

=head1 NAME

examples/pir/substr.pir - playing with substr

=head1 SYNOPSIS

    % ./parrot examples/pir/substr.pir

=head1 DESCRIPTION

A excuberating C<substr> version of "Hello World".

=cut

.sub "example" :main
        $I2 = 1
        $I1 = 0
        $S1 = "Hello World"
        $I3 = 0
        $I4 = 0
        $I5 = length $S1
WAX:    $S2 = substr $S1, $I3, $I4
        print  $S2
        print  "\n"
        $I4 = $I4 + $I2
        if $I4 == $I5 goto WANE
	branch WAX
WANE:   $I1 = length $S1
        print  $S1
        print  "\n"
        chopn  $S1, 1
        unless $I1 == $I3 goto WANE
DONE:
.end

# Local Variables:
#   mode: pir
#   fill-column: 100
# End:
# vim: expandtab shiftwidth=4 ft=pir:
