home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!olivea!sgigate!odin!sierra.corp.sgi.com!stantz
- From: stantz@sierra.corp.sgi.com (Mark Stantz)
- Newsgroups: comp.lang.perl
- Subject: Newbie question from an old hand: ?? vs //
- Message-ID: <1993Jan24.011910.10654@odin.corp.sgi.com>
- Date: 24 Jan 93 01:19:10 GMT
- Sender: news@odin.corp.sgi.com (Net News)
- Organization: Silicon Graphics, Inc.
- Lines: 42
- Nntp-Posting-Host: sierra.corp.sgi.com
-
-
- The Camel book says:
-
- ?PATTERN?[i][o]
-
- This is just like the /PATTERN/ search, except that it matches
- only once between calls to the reset operator, so it finds the
- first occurrence of something rather than the last.
-
- Two years ago, I apparently misread this as:
-
- This is just like the /PATTERN/ search, except that it finds the
- first occurrence of something rather than the last.
-
- Consequently I would have expected the following program:
-
- #!/usr/local/bin/perl
- $f = "perl.is.great";
-
- $f =~ /\./;
- print "$` $'\n";
- $f =~ ?\.?;
- print "$` $'\n";
-
- to print:
-
- perl is.great
- perl.is great
-
- But instead I get:
-
- perl is.great
- perl is.great
-
- Okay, so I was confused. What's the correct behavior? Well, after
- having read over the documentation for //, ?? and reset, I can't seem to make
- // and ?? do anything differently, and have decided that I don't really
- understand what the Camel book is trying to tell me. Can someone post a code
- fragment that shows // and ?? doing different things? Everything I've tried
- gives me the same behavior for both of them. I've also checked the FAQ.
-
- -Mark
-