use strict; use warnings; use XML::Twig; use XML::Simple; use DBI; my $dbname="sample"; my $dbh=DBI->connect("DBI:mysql:$dbname",'root',''); print "Database connected\n"; # Get an array of hashes my $recs = $dbh->selectall_arrayref('SELECT * FROM test',{ Columns => {} }); # Convert to XML where each hash element becomes an XML element my $xml = XMLout( {records => $recs}, NoAttr => 1 ); my $a=scalar($xml); print "$a"; #### use strict; use warnings; my $color1="chr,red,green,yellow"; my @color1=split(',',$color1); my @colors=("red","black","blue","white","green","orange","yellow","pink", "purple","violet","cyan","magenta","navy","brown","gold","lime", "gray","burgundy","silver","clear","teal"); my $color; foreach $color(@color1){ my $i=0; if ($color eq $colors[$i]){ print "$color here\n"; } $i++; }