Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I was given a job to manipulate MIF files and decided to do the job in PERL for it's powerful text manipulating capabilites. A MIF file is another method to represent a FrameMaker file which contains all these tags similar to html.

What I need to do (and this is where I need help) is to delete any strike-through text in the file. Looking at the MIF file at hand, I noticed what tags I have to remove.

For example, here are the MIF tags that represents something that is strike-through.

<ParaLine <Font <FTag `'> <FStrike Yes> <FChangeBar Yes> <FLocked No> > # end of Font <String `There are at least two indications that the MM can re'>

If you look at the MIF file in FrameMaker, there will be this string strike through:

"There are at least two indications that the MM can re"

If I delete the strike-throught text by hand in FrameMaker, the MIF representation would be

<ParaLine <Font <FTag `'> <FChangeBar Yes> <FLocked No> > # end of Font

Note that the above to MIF codes are the same part of the file where text appeared when strike-through and after when it was deleted.

Okay my problem is how do I code the steps to delete any strike-through text. I've a good understand of condtions, functions, regular expressions and such.

What I need to do is if the conditon CODE1 expample is found to delete all the tags that I did in CODE2. So is it legal to declare a varibales such as

my($font) =<<EOFONT; <Paraline <Font <FTag `'> <FStrik Yes> <FChangeBar Yes> <FLocked No> > # end of Font <String 'There are at least two indications that the MM can re'> EOFONT

And I'm stuck after that. So I would apprecitiate if someone could lead me a helping hand to help me solve the problem. And I apologies for my rambling and lack of English skills.

THANKS !!!

Replies are listed 'Best First'.
Re: How to approach this?
by dpuu (Chaplain) on Sep 08, 2002 at 00:13 UTC
    The approach depends on your requirements: if you want a robust script, then you may want to investigate parsers. However, if all you want is a quick hack; then you can think of it as a simple 2-state state machine: have you seen an "Fstrik yes" line since the previous string, or not.
    my $seen_Fstrik_yes = 0; while (<>) { if ($seen_Fstrik_yes && /<String '.*?'>) { $seen_Fstrik_yes = 0; } else { print; $seen_Fstrik_yes |= /<FStrik Yes>/; } }
    This method only works as a quick hack, and assumes a very specific format for its input. --Dave
      Hmmm... parsers? Do you recommend any material?

      I did some NET searching but couldn't fine anything good.