Thread Problem mit der Verwendung von undef (15 answers)
Opened by crojay at 2011-04-20 11:17

sitescriptor
 2011-04-20 13:52
#147898 #147898
User since
2009-08-09
105 Artikel
BenutzerIn
[default_avatar]
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#! /usr/bin/perl
use strict;
use warnings;
use diagnostics;
#---
#my $globalFormPageCfgFile = 'text.txt';
#my $globalFormPageCfgFile = 'textxxxxx.txt';
my $globalFormPageCfgFile = '';
my $pageSizeForForm = '';
#---
sub readFileIntoHash{
my $inputFile = shift || return;
print "using input file $inputFile\n" ;
if (-e $inputFile){
open (HASHFILE,$inputFile) || die "file $inputFile konnte nicht geoeffnet werden\n";
my %exportHash = map { chomp; split /=/, $_, 2; } <HASHFILE>;
close(HASHFILE);
return \%exportHash;
}
else{
print "file $inputFile does not exist, returning undef\n";
return;
}
}
#---
my $Hashref = readFileIntoHash($globalFormPageCfgFile);
if (defined $Hashref){
print "\n%Hashref is defined \n it contains " . keys(%{$Hashref}) ."\n" ;
$Hashref->{'pageCount'} = $pageSizeForForm;
}
else{
print "file $globalFormPageCfgFile does not exist, sorry!\n";
}

Edit: return undef in return geändert
Last edited: 2011-04-20 14:31:05 +0200 (CEST)

View full thread Problem mit der Verwendung von undef