in reply to pattern matching

$string = m/($start)(*)($end)/;
This won't do anything at all. For starters, you need to use =~ for matching and substitutions. The star (*) is a quantifier, and won't do anything unless you put it after something. In fact, it will give you an error the way you have it now, since it doesn't follow anything. Maybe something like this will be improved:
$string =~ /$start(.*?)$end/s;
As an aside, you probably want to start getting used to use strict (although not absolutely necessary in such a small script you have here). Also, CGI::Carp qw/fatalsToBrowser/ will send fatal messages to the browser, making it easier to debug.

Update: match newlines and no case sensitivity. Thanks Juerd and cLive ;) I figured I would miss something! :)

Update: as Yves pointed out, (.*?) would be the best way to go! Thanks, Yves.

- Derek Soviak

Replies are listed 'Best First'.
(cLive ;-) Re: pattern matching
by cLive ;-) (Prior) on Jan 16, 2002 at 22:39 UTC
    Nearly there:
    $string =~ /$start(.+?)$end/s;

    The case insensitivity isn't needed in this case, but slurping everything up as one line is.

    Then the match is stored in $1.

    You don't need the quotemeta in this case (as Yves points out below), but I guess it's good practice to get into until you know *all* regex meta characters.

    cLive ;-)

Re: Re: pattern matching
by Juerd (Abbot) on Jan 17, 2002 at 00:51 UTC
    The dot (.) matches anything under the sun; it's a wildcard.
    Your sun has no newlines :)

    To put newlines under the sun, use the /s modifier.

    2;0 juerd@ouranos:~$ perl -e'undef christmas' Segmentation fault 2;139 juerd@ouranos:~$