in reply to Re: Re: Reducing a line read into $_
in thread Reducing a line read into $_
The '?' gives you non-greedy matching. It shouldn't matter on the data that we've been shown, but if there's a chance that the data will have another ']' character later in the string, then the '?' becomes essential. Compare these:
$_ = '[Remove this] and nothing else'; s/\[.*\]//g; print; $_ = '[Remove this] and [nothing] else'; s/\[.*\]//g; print;
and then try then again with the '?'.
--
"Perl makes the fun jobs fun
and the boring jobs bearable" - me
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: Reducing a line read into $_
by Daniellek (Sexton) on Jan 04, 2001 at 16:13 UTC | |
by repson (Chaplain) on Jan 04, 2001 at 16:55 UTC | |
by davorg (Chancellor) on Jan 04, 2001 at 17:12 UTC | |
by repson (Chaplain) on Jan 04, 2001 at 17:42 UTC |