This little program worked as I expected:

my @x = ( "abc\n", "defg\n" );
for @x -> $k {
    print($k);
    # length() and bytes() seem not implemented yet (?) ...
    #     so try to get length via split
    my $len = +split("", $k);
    say("len=$len");
}

So far so good. Now try this instead:

my @x = ( "abc\n", "defg\n" );
for @x {
    print($_);                 # ok
    # print;                   # yet this does not print anything
    my $len = +split("", $_);  # this works
    # my $len = +split("");    # this fails (no compatible split found)
    say("len=$len");
}

This one also ran ok (note: run with a text file argument @ARGS[0]):

my $fh = open(@ARGS[0]);
for =$fh {
    print($_);
    my $len = +split("", $_);
    say("len=$len");
}

However, I'm a bit confused because S02 states:

Input from a filehandle is no longer done with angle brackets.  Instead
of

    while (<HANDLE>) {...}

you now write

    for *$handle {...}

Now since "for =$fh {...}" works with Pugs yet "for *$fh {...}" does
not work, which needs updating: Pugs or S02 or both ... or have I
misunderstood? :-)

/-\


Find local movie times and trailers on Yahoo! Movies.
http://au.movies.yahoo.com

Reply via email to