I am migrating an Excel spreadsheet into MySQL, and as a part of that, I need to get out a string which is an invoice reference from comment fields. The following gets the info out of mysql and prints out matching lines. I don't know enough about perl yet to get out the string that I want. I'll show some sample output below, showing what I want, and what I don't.
Sample output looks like this
I tried split() but couldn't get my pattern matching to work, as well as a few other ideas, but I just plain don't have enough experience with perl to get it right. Any suggestions would be appreciated.
Code:
$sel = "select Bill_ID, OurRef, YourRef, CostAccepted, DateSent, PONumber, GlulamValue, Comment from Book1";
$db_bdb= DBI->connect('dbi:mysql:database=contacts;host=localhost:3306', $user, $pw, { RaiseError => 1, AutoCommit => 1 });
$rows = $db_bdb->selectall_arrayref($sel);
foreach $row(@$rows){
#misc code goes here for doing stuff with all the other data
if (@$row[7] =~ m/DES16-/ ) {
$invoice = @$row[7];
print "$invoice\n";
}
}
Sample output looks like this
Code:
DES16-184
DES16-183jm
DES16-183jm
[COLOR=red]Inv no. DES16-183jm[/color] <- do not want Inv no.
DES16-146
DES16-146
I tried split() but couldn't get my pattern matching to work, as well as a few other ideas, but I just plain don't have enough experience with perl to get it right. Any suggestions would be appreciated.