Home > Generale > Reverse file in Perl

Reverse file in Perl

#!/usr/bin/perl -w

use strict;
use warnings;

open FILE, "<".$ARGV[0];
my @LINES = <FILE>;

for(my $i = scalar(@LINES) - 1; $i >= 0; $i--)
{
    print $LINES[$i];
}
Tag:
  1. Nessun commento ancora...
  1. Nessun trackback ancora...