How do i reverse the contents of a file in perl?
-
Link: http://perldoc.perl.org/functions/reverse.html
You can use the reverse function.
The program
$ cat myperl6 #!/usr/bin/perl print reverse <STDIN>;
The data
$ cat datafile 10.70.50.1 jennifer 10.70.50.2 nicole 10.70.50.3 cameron
The ouput
Pass in the datafile with a redirection$ ./myperl6 < datafile 10.70.50.3 cameron 10.70.50.2 nicole 10.70.50.1 jennifer
© Lightnetics 2024