Another way to go:
my $lastline;
open(FILE,"test789.pl") || die "Couldn't open \"test789.pl\" for reading!\n";
while(<FILE>){
$lastline = $_;
}
print "\"$lastline\"\n is the last line.\n";
-----Original Message-----
From: balaji venkat [mailto:[EMAIL PROTECTED]
Sent: Wed 8/25/2004 8:56 PM
To: Jeremy Kister; [EMAIL PROTECTED]
Cc:
Subject: Re: get last record in a file
The following code will do the required task.
#! /usr/bin/perl
open (FILE,"test789.pl");
@array1 = <FILE>;
$last = pop(@array1);
print $last;
--- Jeremy Kister
<[EMAIL PROTECTED]> wrote:
> On Wednesday, August 25, 2004 6:15 PM, I wrote:
> > not extensively tested:
>
> this is a bit more tested:
>
> #!/usr/local/bin/perl
>
> open(F, "file.txt");
> while(<F>){
> chomp(my $line = $_);
> my ($key) = $line =~ /^(\S+)\s/;
> $hash{$key} = $line;
> }
> close F;
>
> foreach my $value (values %hash){
> print "$value\n";
> }
>
> Jeremy Kister
> http://jeremy.kister.net/
>
> --
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
> <http://learn.perl.org/>
> <http://learn.perl.org/first-response>
>
>
>
___________________________________________________________ALL-NEW Yahoo!
Messenger - all new features - even more fun! http://uk.messenger.yahoo.com
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>