Hello monks
I'm using unpack to extract fixed width fields from a text file that I need to convert to csv. Because the text in the fields is shorter than the field width I want to trim the whitespace, and there's an added complication of the csv file having fields that aren't in the fixed width file.
At the moment I'm doing the most straight forward thing like so (minus the string trimming):
my ($catno, $desc, $pack, $min, $gst, $cost, $unitcost, $retail, $barc
+ode) = unpack("A7 x2 A30 A4 A4 x13 A7 x15 A8 A8 A8 x13 A13", $_);
print CSTORE_OUT join(", ", "", "", $catdesc, "", "", "", "", $catno,
+$barcode, $desc, $unitcost, "", "", "", $retail, $pack, $gst, "", "")
+."\n";
Is there a one liner I can use to unpack, trim and join?
TIA