in reply to Re: "Use of uninitialized value" with many variables
in thread "Use of uninitialized value" with many variables

Although I agree with your suggestion of using a hash in this instance, I would actually code it slightly differently.
my %txt = map { $_ => '' } qw{AnniversaryDate BirthDate EmailAddr FaxNo MobileMo ... };

When initializing hash keys all to the same value I've found this idiom helps me make fewer mistakes. It also means less repetitive typing. (For those of us who type slowly, that's important.)

G. Wade

Replies are listed 'Best First'.
Re^3: "Use of uninitialized value" with many variables
by Aristotle (Chancellor) on Oct 06, 2003 at 03:14 UTC
    my %txt; my @field = qw( AnniversaryDate BirthDate EmailAddr FaxNo MobileNo ... ); @txt{@field} = ('') x @field;
    Update: corrected thinko as per CombatSquirrel's reply.

    Makeshifts last the longest.

      Actually, '' x @field just concatenates @field empty strings and returns that string. This still causes the warning.
      You probably had a typo, intending to say @txt{@field} = ('') x @field;.
      Cheers,
      CombatSquirrel.
      Entropy is the tendency of everything going to hell.

      I still stumble over the hash-slice syntax. I guess I just have to keep working with it.

      Thanks for the reminder.

      G. Wade