in reply to Testing Hash Arrays

I cant figure out why this doesnt work...

I can't figure ou what you are trying to do.
while (EXPR) { ... } do (EXPR) { ... }
is not even close to valid Perl. I think you need to reread perlsyn before proceeding.

Also, you should use $data{key}, not @data{key}.

@data{value} != "" || null
is also quite wrong.
Fix the sigil:
$data{value} != "" || null
Use ne for string comparisons:
$data{value} ne "" || null
You can't do $var == value || value. It needs to be expanded to $var == value || $val == value: $data{value} ne "" || $data{value} == null
The logic makes no sense. Fixed:
$data{value} ne "" && $data{value} != null
Use defined to check if something is not null: (It's called undef in Perl.)
$data{value} ne "" && defined($data{value}
You need to check defined first to avoid a warning:
defined($data{value}) && $data{value} ne ""

Replies are listed 'Best First'.
Re^2: Testing Hash Arrays
by Snowman11 (Novice) on Jun 27, 2005 at 16:32 UTC
    Not valid..might help if i give u the entire code this is where im at now.
    #!/perl/bin/perl sub adduser{ print "\nI am in the adduser array now"; } #create the array my @data = ( { query => 'First Name',}, { query => 'Firt Name', }, { query => 'School', }, { query => 'Phone', }, { query => 'Position', }, { query => 'Role', }, ); while (1) { #greeting system("cls"); print "iT For Dominica User Database:\n", "Enter the Number then enter the value.\n"; #number the amt of items in list for (my $i = 0; $i < scalar @data; ++$i) { print "\t", $i + 1, ". ", $data[$i]{query}, ": ", $data[$i]{value} + || "", "\n"; } print "\t0. Done\n"; print "Type a number to choose to change: "; my $number = <STDIN>; chomp($number); if ($number > 6){ print "Type a number to choose to change: "; $number = <STDIN>; chomp($number); next; } elsif ($number == 0 || $number > 6) { last; } --$number; print "\n\nPlease enter your ", $data[$number]{query}, ": "; $data[$number]{value} = <STDIN>; chomp($data[$number]{value}); }; print "While statement"; #if the fields are not filled in do this while(scalar @data{value} eq "" || null){ &adduser;#goes back to asking for array members last; if(scalar @data{value} ne "" || null){ #if the Value +s are present Print 'em for ($c1 = 0; $c1 < scalar @data; ++$c1){ print $data{value} . "\n"; }#end of for(); };#end of if{}; }
      Untested, but lots of stuff fixed. Changes marked with "!!!!"
        Thanx for the corrections and tips