in reply to store array as a hash

I think your usage of reading line-by-line from $abc is not what the documentation of Text::CSV recommends:

... while ( my $row = $csv->getline( $fh ) ) { ...

For the matter at hand, you seem to want to do queries by (only) the server id, and then output the row associated with that server? The easiest way is to load all your data into a hash then and use the server id as the hash key:

my %server_info; while ( my $row = $csv->getline( $abc ) ) { my @columns = $csv->fields(); my $server_id = $columns[0]; $server_info{ $server_id } = \@columns; } my $query = $ARGV[0]; print "Searching for server id '$query':"; use Data::Dumper; my $info = $server_info{ $query } || 'No results found'; print Dumper $info;

Replies are listed 'Best First'.
Re^2: store array as a hash
by luckysing (Novice) on Jun 29, 2010 at 17:22 UTC

    Tx for the help monks:P