The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

import-bot (20211) [Avatar] Offline
#1
[Originally posted by philarete]

In chapter 4, you imply that the /o modifier is, like the /e modifier, only
useable with the s/// operator, not with the m// operator. You end the section
on "match modifiers" on page 68 by saying "The final modifier is x." Then you
go on you explain the /o modifier in the "substitution modifiers" section.

But according to my understanding, /o is just as usable with m//. I might well
write a minature grep program like this:

#!/usr/bin/perl -w

my $pattern = shift;

while (<>smilie {
print if m/$pattern/o;
}

__END__

Since I know that $pattern isn't going to change, it helps to add the /o
modifier.
import-bot (20211) [Avatar] Offline
#2
Re: ch 4 - regex modifier /o
[Originally posted by dave]

> In chapter 4, you imply that the /o modifier is, like the /e modifier,
> only useable with the s/// operator, not with the m// operator. You
> end the section on "match modifiers" on page 68 by saying "The final
> modifier is x." Then you go on you explain the /o modifier in the
> "substitution modifiers" section.
>
> But according to my understanding, /o is just as usable with m//. I
> might well write a minature grep program like this:
>
> #!/usr/bin/perl -w
>
> my $pattern = shift;
>
> while (<>smilie {
> print if m/$pattern/o;
> }
>
> __END__
>
> Since I know that $pattern isn't going to change, it helps to add
> the /o modifier.

Having reread the pages you mention (pages 68-70 for those of you
reading along at home) I start to wonder what I was on when I wrote
that section.

To clarify. The /o modifier can be used with both m// and s///. When
used with s///, it only works on on the search pattern, _not_ on
the replacement pattern.

Wonder how I'm going to work all that into the errata smilie

Dave...