How can I produce a unique value key to be paired with my _rec_key_
field name? I am producing a datafile. I was looking at using an MD5 value as my key or any other suggestions you have to making sure this is unique. I'm not familiar with how to extract this value.
The format of the file should look something like this:
__rec_key__^amd5val^ex_id^a1^einum^a2609^euser^aJoe^e^d
__rec_key__^amd5val^ex_id^a2^einum^a2609^euser^aBob^e^d
Basically, enclosing the value with ^a
and ^e
and ending the rec with ^d
My sample data table:
+------+------+------+
| x_id | inum | user |
+------+------+------+
| 1 | 2608 | Joe |
| 2 | 2609 | Bob |
+------+------+------+
My code thus far is this...which just produces my output, without the md5 unique value.
I would need the value to be paired with _rec_key_
my $data = '';
my $dbh = DBI->connect("DBI:mysql:test:localhost:3306");
my $sth = $dbh->prepare("select x_id, inum, user from mytest");
$sth->execute();
while (my($x_id, $inum, $user) = $sth->fetchrow_array() ) {
$data = $data. "__record_key__^a$x_id^e^a$inum^e^a$user^e^d";
}
$sth->finish;
$dbh->disconnect;
print $data;