in reply to Re^2: basic question:how to print a reversed array from STDIN
in thread basic question:how to print a reversed array from STDIN

Dear ikegami,

I had never have the intention to submit this little piece of code to Perl 6 core modules...

For me, it was just a funny variation on chomp.

To be constructive, please give some examples because i can't reproduce two of your three remarks

Laziness, impatience, hubris and why not humility.

hth,
PooLpi

'Ebry haffa hoe hab im tik a bush'. Jamaican proverb

Replies are listed 'Best First'.
Re^4: basic question:how to print a reversed array from STDIN
by ikegami (Patriarch) on Dec 05, 2008 at 10:37 UTC
    I use an in-memory file, but a real file will do just as well.
    { my $f; { open(my $fh, '>', \$f) or die $!; print $fh "abc"; } { open(my $fh, '<', \$f) or die $!; chop( $_ = <$fh> ); print chop while $_; # ba print"\n"; } } { my $f; { open(my $fh, '>', \$f) or die $!; print $fh "012\n"; } { open(my $fh, '<', \$f) or die $!; chop( $_ = <$fh> ); print chop while $_; # 21 print"\n"; } }