Dave Adams wrote:
> Larsen,
> 

Hi Dave.  My name is Errin.  Larsen is my surname.

Please, when posting replies, post to the list.


> I am afraid I cannot get your suggested code to work.  Especially
> line that reads "foreach reverse 0..$n;" 

<SNIP>

> 
> On 7/25/05, Larsen, Errin M HMMA/Information Technology Department
> <[EMAIL PROTECTED]> wrote: 
>> 
>> I shortened this up a bit:
>> 
>> perl -e 'open FH, "$filename"; @lines=reverse <FH>; print $lines[$_]
>> foreach reverse 0..$n;' 
>> 
>> Where "$filename" is replaced with the name of the file and "$n" is
>> replaced with the number of lines to display.
>> 


First, can you tell us about your environment?  UNIX or Windows? Other
OS?  What version of Perl?  Please give us more details.

Second, you can try making the line more "correct":

  perl -e 'open FH, "<$filename"; @lines=reverse(<FH>);
print($lines[$_]) foreach(reverse(0..$n));'

See how that line does.

Third, as I mentioned, the '$n' part of that command line needs to be
replaced with a number, AND the '$filename' part of that command line
needs to be replaced with a file name.  If I have a file named
'foo.bar', and I want to see the last 25 lines of it, I would type:

  perl -e 'open FH, "foo.bar"; @lines=reverse FH; print $lines[$_]
foreach reverse 0..25;'

I hope that is helpful!

--Errin

PS  I just re-read you question (above) and I realized maybe you hadn't
realized the code I posted was all on one command line. Make sure you
don't hit 'enter' until the entire command line is typed in.
 

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to