in reply to A pattern that matches three consecutive copies...

I have tried this problem with the solution that they gave in the book but it didn't work
Since the answer given there has been presented in classrooms hundreds of times to thousands of people and read by probably a hundred times that many again home readers who bought the book and worked through the exercises, and you would be the first to say it "didn't work", I suspect something is more off kilter in your transcription or understanding of the answer than something wrong in the book. Just looking at the odds. {grin}

Please post precisely what you tried, what you expected, and what you got. I bet we can sort it out from there.

-- Randal L. Schwartz, Perl hacker

  • Comment on •Re: A pattern that matches three consecutive copies...

Replies are listed 'Best First'.
Re: •Re: A pattern that matches three consecutive copies...
by WarrenBullockIII (Beadle) on Jun 09, 2002 at 15:55 UTC
    In the book under appendix A it says: Here is one way to do it:
    /($what){3}/
    so this is what I tried to do in my script:
    #!/usr/bin/perl -w use strict; my $what = 'fred|barney'; if($what =~ /($what){3}/){ print "$&"; } else{ print "no match\n"; }
      Well, fred|barney as a string doesn't have three things that match the regex (fred|barney) in a row. So I would expect it to say "no match". Are you getting something different from that?

      -- Randal L. Schwartz, Perl hacker

        Yes actually I am getting it to say no match. Thats what I expect it get too! So I guess I don't uderstand the question in the book then...