[DOCS]
[parrot.git] / examples / pir / substr.pir
blob662a01f5ad30a1e97db668d394f943b8c1085cca
1 # Copyright (C) 2001-2008, The Perl Foundation.
2 # $Id$
4 =head1 NAME
6 examples/pir/substr.pir - playing with substr
8 =head1 SYNOPSIS
10     % ./parrot examples/pir/substr.pir
12 =head1 DESCRIPTION
14 A excuberating C<substr> version of "Hello World".
16 =cut
18 .sub "example" :main
19         I2 = 1
20         I1 = 0
21         S1 = "Hello World"
22         I3 = 0
23         I4 = 0
24         I5 = length S1
25 WAX:    S2 = substr S1, I3, I4
26         print  S2
27         print  "\n"
28         I4 = I4 + I2
29         if I4 == I5 goto WANE
30         branch WAX
31 WANE:   I1 = length S1
32         print  S1
33         print  "\n"
34         chopn  S1, 1
35         unless I1 == I3 goto WANE
36 DONE:
37 .end
39 # Local Variables:
40 #   mode: pir
41 #   fill-column: 100
42 # End:
43 # vim: expandtab shiftwidth=4 ft=pir: