in reply to regex issue

This seems to do the trick. I took the liberty of reading from <DATA> instead of your input filehandle, and writing just to standard output instead of to a filehandle. I just did that for the sake of making the solution easy to read. You can easily adapt it to read from any filehandle and print to any other filehandle.

my $number = 02; while ( <DATA> ) { last if /^$number/; } while ( <DATA> ) { last if /^\d+/; print if /^-/; } __DATA__ 01 - three cans - one file - three balls 02 - none - yes coffee 03

I hope this helps...


Dave

Replies are listed 'Best First'.
Re: Re: regex issue
by Not_a_Number (Prior) on May 11, 2004 at 08:27 UTC
    my $number = 02;

    I can only get your code to work by quoting $number, like so:

    my $number = '02';

    presumably because perl converts "02" (unquoted) to a standard number...

    dave

Re: Re: regex issue
by Anonymous Monk on May 11, 2004 at 04:50 UTC
    thanks all ,, thats a lot of help. :)