#!/usr/local/bin/perl # $nlines = 5; $datafile = '/home/hiroshi/vtpwork/data.txt'; if( $ENV{"REQUEST_METHOD"} eq "POST"){ $n_read = $ENV{"CONTENT_LENGTH"}; if( $n_read >= 2000){ $n_read = 2000; } $n_read = sysread( STDIN, $txt, $n_read); }else{ $txt = $ENV{"QUERY_STRING"}; } # open( FH, "+<$datafile"); lock( FH, 2); seek( FH, 0, 2); $txt =~ s/[\r\n]//g; print FH "$txt\n"; close( FH); open( FH, "$datafile"); @data = ; close( FH); $en = $#data; $st = $en - $nlines + 1; print "Content-type: text/plain\n\n"; print $#data . "\n"; print @data[$st..$en];