in reply to RE: Writing files in reverse..and more
in thread Writing files in reverse..and more

Cheat! You just corrected the first problem that I saw (incorrect arguments to rindex).

The other problem is that it runs all of the lines together, you need to print "\n" at the end of each line like this:

print scalar( reverse substr( $_, 0, rindex($_," //") ) ), "\n" while +(<>);

but if we're playing golf then you can save a couple of strokes by using map

print map { scalar reverse(substr( $_, 0, rindex($_," //") )), "\n" } +<>;
--
<http://www.dave.org.uk>

European Perl Conference - Sept 22/24 2000, ICA, London
<http://www.yapc.org/Europe/>

Replies are listed 'Best First'.
RE: RE: RE: Writing files in reverse..and more
by cwest (Friar) on Jul 28, 2000 at 21:23 UTC
    A slightly more full featured try with a few more strokes (outside the map), using davorgs origional post meathod of spliting.
    { local $\="\n" => select STDOUT; # Or what ever FileHandle map { print scalar reverse( (split m!\s+//!)[0] ) } <DATA> }
    Enjoy!
    --
    Casey