Ich habe ein Problem in Perl. Ich hoffe, dass mir jemand helfen kann.undef-Variable von "if" Bedingung
my $bCommType = 'none';
my %commTypes = (
'none' => '0',
'public' => '1',
'custom_percentage' => '2',
'custom_permeg' => '2',
'custom_flat' => '2',
);
my %rateTypes = (
'custom_percentage' => '%',
'custom_permeg' => '$',
'custom_flat' => 'FLAT',
'none' => 'none',
);
my $commrate = $rateTypes{$bCommType} if ($commTypes{$bCommType} == 2);
meine Ausgabe in $commrate
ist undef
, kann mir jemand helfen, das Problem zu identifizieren?
Was ist Ihre Frage? Du hast vergessen, einen zu fragen. Was möchten wir identifizieren? – simbabque
mein $ commrate = $ rateTypes {$ bCommType} if ($ commTypes {$ bCommType} == 2); Ich bekomme einen undef Wert in meiner Variable. –
[Es heißt Perl, nicht PERL.] (Https://en.wikipedia.org/wiki/Perl#Name) :) – simbabque