Tony Frasketi wrote: > Hello Listers Hello,
> I'm getting the following error when executing the function listed below... It is a warning not an error. > cimagedisp_new.cgi: Use of uninitialized value in hash > element at /.../cimagedisp_new.cgi line 238, <FILE> line 69. perldoc perldiag [snip] Use of uninitialized value%s (W uninitialized) An undefined value was used as if it were already defined. It was interpreted as a "" or a 0, but maybe it was a mistake. To suppress this warning assign a defined value to your variables. To help you figure out what was undefined, perl tells you what operation you used the undefined value in. Note, however, that perl optimizes your program and the operation displayed in the warning may not necessarily appear literally in your program. For example, "that $foo" is usually optimized into ""that " . $foo", and the warning will refer to the "concatenation (.)" operator, even though there is no "." in your program. > 223 #------------------------------------------------------------- > 224 # Build a hash of pricelist names/ids from an inc file > 225 # my(%plhash) = &build_pricelist_hash($plnameid_file); > 226 #------------------------------------------------------------- > 227 sub build_pricelist_hash { > 228 my($file) = @_; > 229 > 230 my(%plhash) = (); > 231 if(!open(FILE,$file)) { > 232 &abort_program("<b>FILE ERROR:</b><br>Can't open file > $file<br>\n[$!]"); > 233 } > 234 my($i) = 0; > 235 while (<FILE>) { > 236 chop $_; > 237 my($name,$id) = split(/\|/,$_); > 238 $plhash{$id} = $_; The variable $id has the value 'undef' and is therefore producing this warning. From the warning message it looks like line 69 of $file does not contain the '|' character. $ perl -le' for ( "one|two", "one two", "one|two|three" ) { my ( $one, $two ) = split /\|/; print defined $one ? ">$one< " : "one=undef ", defined $two ? ">$two< " : "two=undef "; } ' >one< >two< >one two< two=undef >one< >two< Also, you should use chomp() instead of chop(). John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>