Skip to main content


Hi all! I have a bug in my script I can't locate and I'm sure it must be some silly thing.

I am using a SQLite database with a contacts table that includes a field for the date in which the contact was added or edited. This is a DATE type field defined as "editado" date NOT NULL.

I search for a group of contacts by doing this (nomap is a string field with name and lastname):

sub cntSearch( $srch ) { my @result = (); my $tosrch = $srch; $tosrch =~ s/([\\%_'"\[\]])/\\$1/g; # LIKE no admite $dbh->quote() $sth = doSQL( "SELECT * FROM contactos WHERE nomap LIKE '%$tosrch%' ORDER BY nomap" ); while ( $hr = $sth -> fetchrow_hashref() ) { utf8::decode( $hr->{nomap} ); push @result, $hr; } return @result; } 

At this point, if I read $hr->{editado}, I get the string I want (a date in the YYYY-MM-DD format). But when I do this:
my @cntlist = cntSearch( $srch ); for ( @cntlist ) { my ( $codigo, $nomap, $ref, $editado ) = ( $_->{codigo}, $_->{nomap}, $_->{referencia}, $_-->{editado} ); } 

the variable editado gets the value 1.

The actual code is more complex but this is the gist of it and I think the other stuff is not related.

Any advice on this would be appreciated!

submitted by /u/elbitjusticiero
[link] [comments]