in reply to regular expression

What do you mean by store a value "to the start of another '{'"? Could you provide an example of what your output should look like?

In the meantime here are some tips:

I'd post some code to illustrate but I'm just a little concerned this is a homework problem. If there is something unclear in what I have written above please ask. Try using a flag on your own. If you are still stuck, update your post with the code your wrote trying to use a flag to find the author values.

Best, beth

Replies are listed 'Best First'.
Re^2: regular expression
by jbt (Chaplain) on Aug 16, 2009 at 13:55 UTC
    Maybe something as simple as:

    my $flag; while(<DATA>){ if (/^{(\w+)}/) { $flag = $1; } elsif ($flag =~ m/AUTHOR/) { # "store" values here } }
      The output should be
      By June Fletcher JOURNAL Richard White MacCUBBIN
      Line below the {AUTHOR} and start of another '{'

        My homework:

        my $flag = 0; while (<DATA>) { ($flag = ($1 eq "AUTHOR"), next) if /\{(\w+)\}/; print $_ if $flag; }

        No need to chomp... record terminator will be used in the output.