#!/bin/sh
# -*- perl -*-
# This code allows us to start perl from our path or an environment variable
# rather than hardcoding a path into the #! line.  It works from sh or csh.
(exit $?0) && eval 'exec ${QPERLQ-perl} -x $0 ${1+"$@"}'
if (! $?QPERLQ) setenv QPERLQ perl
exec $QPERLQ -x $0 $argv:q

#!/usr/local/bin/perl -w
#
# $Id: reverse_lines,v 1.3 1998/05/10 14:29:51 ejb Exp $
# $Source: /home/ejb/scripts/RCS/reverse_lines,v $
# $Author: ejb $
#


$whoami = ($0 =~ m,([^/]*)$,) ? $1 : $0;

&usage unless (scalar(@ARGV) == 1);
($file) = (@ARGV);
# Don't say wc -l $file -- the result may include the filename
chop($lines = `cat $file | wc -l`); 

@lines = ();
open(FILE, "<$file") || die "$whoami: can't open $file\n";
$i = $lines - 1;
while (<FILE>)
{
    $lines[$i] = $_;
    $i--;
}
for (@lines)
{
    print;
}

sub usage {
    die "Usage: $whoami file\n";
}
