in reply to Re^2: Sorting an array of hashesin thread Sorting an array of hashes
perl arraydelete.pl Use of uninitialized value within @x in print at arraydelete.pl line 6 +. 1245 [download]
#! perl use warnings; use strict; my @x = (1,2,3,4,5); delete $x[2]; for (0..4) { print $x[$_] if exists ($x[$_]) } [download]
perl arraydelete.pl 1245 [download]
You get the result you want, but the semantic is not what you indicate by using exists so I'd rather use defined in that case. #! perl use warnings; use strict; my @x = (1,2,3,4,5); delete $x[2]; for (0..4) { print $x[$_] } [download] Run it to produce: Use of uninitialized value in print at checkifexists.pl line 6. 1245 [download] So, the element exists, but it's value is undefined.
#! perl use warnings; use strict; my @x = (1,2,3,4,5); delete $x[2]; for (0..4) { print $x[$_] } [download]
Use of uninitialized value in print at checkifexists.pl line 6. 1245 [download]