"Randal L. Schwartz" wrote:
>
> >>>>> "jbarry" == jbarry <[EMAIL PROTECTED]> writes:
>
> jbarry> /(.*?),/; #pattern matching. Grabs everything up to the first comma.
> jbarry> (The material number)
> jbarry> $key = $1;
>
> NEVER use $1 unless it's in the context of a conditional based on the
> pattern match. If the match fails (perhaps unexpectedly), you'll
> be getting the *previous* $1, and that will certainly not be what
> you had expected.
if (/(.*?),/) {
$key = $1;
}
should be safe here, assuming 'in scalar context returns true if it
succeeds, false if it fails.' means that false is 0 or undef :)
Cheers,
- Matt