my $in=join (", ", (map { $_ = "'$_'" } @one)); $sql="SELECT * FROM sistema WHERE codigo_inscripcion IN ($in) and matricula='$matricula'"; $pdbh=$dbh->prepare($sql); $pdbh->execute(); # stuff here! while (my $ref = $pdbh->fetchrow_hashref()) { if($ref->{'mon'} != ''){$mon="Mon$ref->{'mon'})} if($ref->{'tue'} != ''){$mar="Tue$ref->{'tue'}"} if($ref->{'wed'} != ''){$mie="Wed$ref->{'wed'}"} if($ref->{'thu'} != ''){$jue="Thu$ref->{'thu'}"} if($ref->{'fri'} != ''){$vie="Fri$ref->{'fri'}"} if($ref->{'sat'} != ''){$sab="Sat$ref->{'sat'}"} if($ref->{'sun'} != ''){$dom="Sun$ref->{'sun'}"} } $pdbh->finish(); exit; if ($mon ne ''){ $lun=~ /([A-Za-z]*)([0-9]*)\/([0-9]*)/; for($z=$2;$z<$3;$z++) { push (@soft, "$1$z"); } push (@soft, "$1$3"); print @soft; exit;