Re: HowTo parse huge Files




cadetg@xxxxxxxxxxxxxx schrieb:


my %lookingFor;
# keys => different name of one subset
# values => array of one subset

my $fh = new FileHandle "< largeLogFile.log";
while (<$fh>) {
foreach my $subset (keys %lookingFor) {
foreach my $item (@{$subset}) {
if (<$fh> =~ m/$item/) {
my $writeFh = new FileHandle ">> myout.log"; print $writeFh <
$fh>;
}
}
}


Your code will "copy" the following lines from "lagreLogFile.log"
after successful patternmatch into "myout.log"
This may be time-consuming... ...and possible not what you expected?
(use $_ instead of <$fh> in your "if" and in your "print")

REs may lead to "endless matching". Please show some samples.

study may/may_not help before patternmatching. (perldoc -f study)

Thomas

.



Relevant Pages

  • CSV dB script help
    ... # It uses the order of those keys for the order it displays them. ... # printpagesub and prepares the date for the writeupdate# ... # We need the array, ... foreach $num ...
    (comp.lang.perl.misc)
  • Re: CSV dB script help
    ... > # It uses the order of those keys for the order it displays them. ... > # printpagesub and prepares the date for the writeupdate# ... > # We need the array, ... > foreach $num ...
    (comp.lang.perl.misc)
  • Re: Problems Referencing Hash of Arrays
    ... I've a hash that's a dictionary. ... case), get the desired words into an array, and all this works. ... What DOESN'T work is when I try to use the user's entries as keys to ... foreach $acro { ...
    (perl.beginners)
  • How to prevent duplicated entry in array of the hash
    ... if any one knows how to prevent a duplicated entry in array of ... the hash: here is what I need to do. ... foreach my $sys { ... # Here I know I should check to see if the keys & value exits ...
    (comp.lang.perl.misc)
  • How to prevent duplicated entry in array of the hash
    ... if any one knows how to prevent a duplicated entry in array of ... the hash: here is what I need to do. ... foreach my $sys { ... # Here I know I should check to see if the keys & value exits ...
    (comp.lang.perl.misc)