in reply to Re: Combining two Reg Expressions with substitution
in thread Combining two Reg Expressions with substitution

But wouldn't that just work for a single line? The next line that contained gregarious would have its first occurrence footnoted. Which isn't what the OP was asking for. I think. Sometimes.

No, wait, I see what it's doing now. OK, feel free to ignore me (which is usually a good idea).

  • Comment on Re: Re: Combining two Reg Expressions with substitution

Replies are listed 'Best First'.
Re: Combining two Reg Expressions with substitution
by Abigail-II (Bishop) on Nov 04, 2003 at 18:16 UTC
    #!/usr/bin/perl use strict; use warnings; $_ = <<'--'; gregarious foo gregarious foo foo gregarious foo gregarious gregarious foo gregarious foo -- s/(gregarious)/\\underline{$1}/g && s/\\underline\{(gregarious)\}/\\footnote{$1}/; print; __END__ \footnote{gregarious} foo \underline{gregarious} foo foo \underline{gregarious} foo \underline{gregarious} \underline{gregarious} foo \underline{gregarious} foo

    Abigail

      So when the entire file has been slurped into the one variable you can operate on it this way. But if the file is being read a line at a time (implied somewhat by cranberry13 variable naming), then Enlil's method is preferable.