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

You don't even have to count how many there are of them:
$_ = '' for my ( $txt_AnniversaryDate, $txt_BithDate, $txt_EmailAddr, $txt_FaxNo, $txt_MobileNo, $txt_Name, $txt_PhoneNo, $txt_PhysicalAddress, $txt_PhysicalCode, $txt_PhysicalCountry, $txt_PhysicalTown, $txt_PostalAddress, $txt_PostalCode, $txt_PostalCountry, $txt_PostalTown, $txt_Sex, $txt_Surname );
(Trick borrowed from TheDamian.)

UPDATE: I had a typo noticed by atcroft.

Replies are listed 'Best First'.
Re: Re: Re: "Use of uninitialized value" with many variables
by davido (Cardinal) on Oct 06, 2003 at 03:25 UTC
    Or use map in void context, which as of Perl 5.8.1 is no longer "costly" (inefficient). As of v5.8.1, map in void context doesn't create a list that just gets thrown away. Hense:

    map { $_ = "" } ($txt_AnniversaryDate, $txt_BithDate, $txt_EmailAddr, $txt_FaxNo, $txt_MobileNo, $txt_Name, $txt_PhoneNo, $txt_PhysicalAddress, $txt_PhysicalCode, $txt_PhysicalCountry, $txt_PhysicalTown, $txt_PostalAddress, $txt_PostalCode, $txt_PostalCountry, $txt_PostalTown, $txt_Sex, $txt_Surname );

    Anything but pretty.


    Dave


    "If I had my life to do over again, I'd be a plumber." -- Albert Einstein