http://www.perlmonks.org?node_id=1193851

bradcathey has asked for the wisdom of the Perl Monks concerning the following question:

I'm reading in a tab delimited text file exported from Excel. The 12th "position" contains a simple 3 or 4 digit number. For some reason that number is coming in as a string, or something I'm not familiar with, and unusable as a number. This is from Dumper:

$VAR1 = [ '1130',

My database query was returning zip so I tested for the veracity of the uniq_id in line 78. The error is:

Argument "\01\01\03\00\0" isn't numeric in multiplication (*) at ./map +tobuildforums.pl line 78.

I did a hex dump and the number looks fine:

1130 = 31 31 33 30

Here's the code:

... use List::MoreUtils qw(uniq); open($fh, '<', 'filetoparse.txt') or die "error $!"; chomp(my @lines = <$fh>); close $fh; my @old_ids; foreach my $line (@lines) { @data = split(/\t/, $line); push @old_ids, $data[12]; } my @uniq_ids = uniq (@old_ids); #get unique ids #step through unique ids for new id using old ids for my $i (0..$#uniq_ids) { print $uniq_ids[$i] * 1; #line 78 of my code to test for a number my $stmt = "SELECT * FROM temp_topics WHERE old_id = ?"; my $topic = $dbh->selectrow_hashref($stmt, undef, $uniq_id[$i]); etc. }

Thoughts on how to handle this?

—Brad
"The important work of moving the world forward does not wait to be done by perfect men." George Eliot