[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Answer to previous question



#!/usr/bin/perl -w
# Perl's prettier, especially when done by an 
# ex-QuickBASIC programmer.   :-)

$output_file = "file1.txt";
$input_file = "file2.txt";

open(INPUT, "$input_file") or die "Couldn't open
$input_file: $!\n";

open(OUTPUT, ">output_file") or die "Couldn't open
$output_file:$!\n";

while(<INPUT>) {
    $line = $_;
    $rev_line = reverse($line);   # Will it work on
scalars?
    print OUTPUT $rev_line;
}
--- KoReE <koree@ameth.org> wrote:
> I found a sed script to do this:
> 
> # Reverse content of each line.
> # Casper Boden-Cummins <casper@wollery.demon.co.uk>
> 
> sed '
> # add newline as a marker
> G
> : next
>   # move char before marker to end of line
>   s/\(.\)\(\n.*\)$/\2\1/
> 
>   # repeat until marker is at beginning
>   t next
> 
> # remove marker
> s/\n//
> '
> 
> 
> It appears to work.
> 
> Koree
> 
> ____________________________________
> Koree A. Smith  | Ameth Technologies
> koree@koree.net | koree@ameth.org
>      http://www.koree.net/
> 
> I was walkin' down the street,
> when I thought I heard this voice say,
> "Say, ain't we walkin' down the same street,
> together on the very same day",
> And I said,
> "Hey senorita, that's astute", I said,
> "Why don't we get together and call ourselves an
> institute"
> 
> 
> 
> -
> To unsubscribe, send email to majordomo@silug.org with
> "unsubscribe silug-discuss" in the body.


__________________________________________________
Do You Yahoo!?
Yahoo! Health - Feel better, live better
http://health.yahoo.com

-
To unsubscribe, send email to majordomo@silug.org with
"unsubscribe silug-discuss" in the body.