[vox-tech] dumb perl question

Peter Jay Salzman vox-tech@lists.lugod.org
Sat, 12 Jan 2002 15:29:46 -0800


i know i should know this by now...

how does one get assignments out of a backreference from a regex match?

in other words, can statements like this

	`wc -l $file` =~ m/\s*(\d+) .*/g;
	$NumberOfPoints = $+;

or this:

	/(\d+).*/;
	$temperature = $+;

be condensed into single line statements?  when i do something like:

	$temperature = /(\d+).*/;

the /(\d+).*/ produces a "1".  i imagine that simply means "yes, i was
able to match the regex".

pete

-- 
The mathematics [of physics] has become ever more abstract, rather than more
complicated.  The mind of God appears to be abstract but not complicated.
He also appears to like group theory.  --  Tony Zee's `Fearful Symmetry'

PGP Fingerprint: B9F1 6CF3 47C4 7CD8 D33E  70A9 A3B9 1945 67EA 951D