Sophie

Sophie

distrib > Fedora > 15 > x86_64 > by-pkgid > 1e007a96761035f261351a68e7601417 > files > 859

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

# Copyright (C) 2007-2009, Parrot Foundation.

=head1 String Operations (continued)

To find the length of a string in PIR, use the length opcode. It works on
any variable containing a basic Parrot string, but not the String PMC.
C<length> returns an integer value, and 0 means an empty string.

=cut


.sub main :main

    $S0 = "Hello"
    $I0 = length $S0
    say $I0

    .local string text
    text = "longer string"
    $I1 = length text
    say $I1

.end

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