Benjamin Jeeves wrote:
> Can someone tell me why my call to build_db() works but when I call
> alert() it will not work as it calls alert but will not enter the
> while loop I my opening the file with
>
> #!/usr/bin/perl

Please add these lines here:

    use strict;
    use warnings;

as together they will cut down dramatically on the number
of unfathomable bugs. You will then need to declare all of
your variables with:

    my $filein;

etc.

> $filein = $ARGV[0];
> open(filein, "$filein");

Filehandles are traditionally all uppercase, and it's not
good to put a variable in quotes unless you have a reason
to.

    open FILEIN, $filein;


I presume you have a call

    start();

somewhere here?

> sub start
> {
>     for(;;) {
>         while ( <filein> ) {
>             build_db();
>             $counter++;
>             alert();
>             $counter1++;
>             print "$counter..$counter1\n";
>         }
>         sleep 50;
>         seek filein,0,1;
>     }
> }
>
> sub alert
> {
>     while( <filein> )
>     {
>         # does some thing on pattern matching
>     }
> }

Are you clear that <filein> will read a line from your input file?
Both your subs 'start' and 'alert' are reading lines from the file,
and 'start' doesn't do anything with the one it reads. If you
have only one line of data in your file then 'start' will read this
line and, as there are no more lines, the while condition in
'alert' will fail immediately. It will therefore return without
doing anything.

It's my guess this is what's happening.

HTH,

Rob




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to