[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

[perl] while løkke til variabel



Følgende piller de linier ud af en logfil der svare til et søgekriterie:

#!/usr/bin/perl

#Åben logfilen eller dø.
open LOG, '/var/log/squid/access.log' or die "Logfilen er ikke tilgængelig, er du Root?\n $! \n";


##Hvad skal vi søge efter
print "Hvilket udtryk vil du søge efter? \n";
my $search = <STDIN>;
chomp ($search);

##Hiv de linier ud der indeholder vores søgestreng

while (<LOG>) {

print if /$search/i;

}

Jeg har to spørgsmål, jeg er helt ny udi perl, er det den smarteste måde at gøre dette på?

I tilfælde af jeg vil arbejde mere med de hits jeg får kan jeg så hive de "fangede" linier over i en variabel før/efter/samtidig med de bliver printet?

/Magnus
--
"Ford, you're turning into a penguin. Stop it."

Douglas N. Adams (1952-2001)

 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2006-02-01, 02:01 CET [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *