Forum Moderators: coopster & phranque

Message Too Old, No Replies

opening a file from cgi... help

         

albbr1

12:16 pm on Oct 26, 2004 (gmt 0)

10+ Year Member



im playing around my first perl cgi script that show me proxy logfile without useless lines.
can perl return lines from a pattern directly opening a file, like 'grep' o 'gawk' in bash?
I try:
 
open LOGFILE, "(< /var/log/foo.log";
@line = reverse <LOGFILE>;
foreach $line(@line)
....

then i split lines and format the output but my problem is that i dont want the entire logfile but only lines that doesn't match with a pattern (to exclude \.jpg¦\.gif¦\.png for example..)

tnx for help in advance.

bnhall

7:55 pm on Oct 26, 2004 (gmt 0)

10+ Year Member



Welcome!

@line = grep!/jpg/, @line;

bnhall

7:57 pm on Oct 26, 2004 (gmt 0)

10+ Year Member



There should be a space after the grep, but the posting keeps removing the space. Weird.

albbr1

9:10 am on Oct 27, 2004 (gmt 0)

10+ Year Member



tnx bnhall, it works great!
but lines i grep from that file are thousands so my next step is find a way to split and autolink this pages.
i have added a counter to my script and im working around something like this:

$linenumber = $linenumber + 1;
if $linenumber == 500 {
generate a page autolinked with other(s)
};

any code idea?
tnx again.
A.

bnhall

4:20 pm on Nov 15, 2004 (gmt 0)

10+ Year Member



Sorry, I'm not sure what you're trying to do. What do you mean "split and autolink"?

runner

11:56 pm on Nov 15, 2004 (gmt 0)

10+ Year Member



I think what he means is that the list of matching lines is very long and he wants to create more than one page to view the results. Maybe display 20 lines on a page then click a link to see the next 20 results.

Is this correct?