in reply to How to store the data fetched from the database in perl
#!/usr/bin/env perl use strict; use warnings; use feature 'say'; use Data::Printer; # populating your hash my %data = map { chomp; $_ => 1 } <DATA>; # for your example, might look something like this: # my %data = map { $_ => 1 } $sth->fetchrow(); # do you mean fetchrow_ +array? # two ways to check whether key exists in hash say "ABC exists" if exists $data{'ABC'}; say "JKL exists" if $data{'JKL'} == 1; p %data; __DATA__ ABC JKL HGJ KJI GHJ LKJ
Output:
{ ABC 1, GHJ 1, HGJ 1, JKL 1, KJI 1, LKJ 1 } ABC exists JKL exists
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: How to store the data fetched from the database in perl
by rajsai28 (Novice) on Jun 11, 2013 at 06:38 UTC | |
by choroba (Cardinal) on Jun 11, 2013 at 06:51 UTC | |
by Neighbour (Friar) on Jun 11, 2013 at 06:53 UTC | |
by frozenwithjoy (Priest) on Jun 11, 2013 at 06:51 UTC |
In Section
Seekers of Perl Wisdom