in reply to There is more than one way (and mine is not the best)

"When I run this with "use warnings" I get a gazillion warnings reading: "Use of uninitialized value in concatenation (.) or string at oeaxe.p line 23, <QIN> line 784." I don't have any idea what this means.

It means what it says :) To get rid of the warning, assign variables an empty string or 0 as appropriate. ie, in this instance:

# change this my ($qnum,$code,$ctext,$ntext,$stext); # to my ($qnum,$code,$ctext,$ntext,$stext)=('','','','','');

Oh, and you're assigning $stext from a split. You might want to amend that too:

$stext = (split(/\s/,$_,2))[1] || '';
Or something like that :) To avoid the warnings, always assign an empty string as an alternative if the assignment may be undefined.

cLive ;-)

updated: added more explanation...

Replies are listed 'Best First'.
Re: Re: There is more than one way (and mine is not the best)
by revdiablo (Prior) on May 26, 2004 at 16:44 UTC
    my ($qnum,$code,$ctext,$ntext,$stext)=('','','','','');

    If it were me, I'd do that like this:

      $_ = '' for my ($qnum,$code,$ctext,$ntext,$stext);

    Basically, I take the precept that counting things is bad. It's easy to mis-count. In this case, trying to make sure you have the same amount of empty strings on the RHS as variables on the LHS involves counting, and thus should be avoided. 8^)