$#{$table} should be either $#${table} or just $#$table
$table is an arrayref so these
should bemy $location = $table[i]->[0]; # missing $ on i my $room = $table[i]->[1];
my $location = $table->[$i][0]; my $room = $table->[$i][1];
and push is for building an array not a hash, so this
push $hdata{$location}=$room;should be
$hdata{$location} = $room;or alternatively
poj#!/usr/bin/perl use strict; use Data::Dump 'pp'; my $table = [ ['Wellbeing Office', 'Pending'], ['Library','Pending'], ['Y219','InProgress'], ['B201','InProgress'], ['B108','InProgress'], ['LAB1','InProgress'], ['C303','InProgress'], ]; my $last_index = $#${table}; my $count = scalar @$table; print " records = $count last index = $last_index\n"; #my %hdata = (); #for my $i (0..$last_index){ # my $location = $table->[$i][0]; # my $room = $table->[$i][1]; # $hdata{$location} = $room; #} #pp \%hdata; my %hdata = (); for my $row (@$table){ my $location = $row->[0]; my $status = $row->[1]; $hdata{$location} = $status; } pp \%hdata;
In reply to Re^3: how to save data to new array after retrieving from sql server
by poj
in thread how to save data to new array after retrieving from sql server
by mhoang
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |