If the hash is defined the running of the program doesn´t couse any problems, but if the hash is undefied I get the error message: "Use of uniintialised value in hash element". The the whole purpose of the code in a larger concept is to look if the hash is defined, if it is so do A if it is not do B. It should therefore not print error messages if the hash is not defined, becouse it may very well be undefined. Do you have any solution to this small problem?#!/usr/bin/perl -w my (%hash); my (@keyarr)=(keys (%hash)); if (defined ($hash{$keyarr[0]}})) {print "hash is defined\n";} else {print "hash is undefined\n";}
2006-02-11 Retitled by planetscape, as per Monastery guidelines
Original title: 'Defied vs. undefined'
In reply to Defined vs. undefined by tamaguchi
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |