Perl split() question (OT)...

Fernando Gleiser fgleiser at cactus.fi.uba.ar
Fri Jul 23 09:05:05 PDT 2004


On Fri, 23 Jul 2004, Steve Bertrand wrote:

> Perl hackers -- Figured someone would have a reasonably quick, easy answer
> for this:
>
> I am trying to read through a file, line-by-line, and I want to extract
> the text in between the [ and ] characters.

This is a job for......capturing parens!!!

Try this:

if ($_=~/\[(.+)\]/) {
	$var=$1;
}

$1 would be the string matched by the regex between ( and )



			Fer


More information about the freebsd-questions mailing list