On Thu, 5 Jul 2001, Tim Musson wrote:

> CO> WAG: try 
> CO> my @Group = split(/_/, $Line[2]) if (defined($Line[2]));
> 
> Thanks, that did it. I should just listen to myself talk sometimes. I
> was just saying to a coworker, "I only want to split if $Line[2] is
> defined"!

BEWARE of this construct, it has a hidden gotcha.  Do this instead:

my @Group;
@Group = split(/_/, $Line[2]) if (defined($Line[2]));

Otherwise, the 'my' is also inside of the 'if', which causes bizarre
problems.

- D

<[EMAIL PROTECTED]>

Reply via email to