Sophie

Sophie

distrib > Fedora > 15 > i386 > by-pkgid > 1e007a96761035f261351a68e7601417 > files > 730

parrot-docs-3.6.0-2.fc15.noarch.rpm

# Copyright (C) 2001-2010, Parrot Foundation.

=head1 NAME

examples/pir/substr.pir - playing with substr

=head1 SYNOPSIS

    % ./parrot examples/pir/substr.pir

=head1 DESCRIPTION

A exuberating 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"
        $S1 = chopn $S1, 1
        unless $I1 == $I3 goto WANE
DONE:
.end

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