Do not use DBI and Perl to do this.
Use MySQL's import utility to load the the file. That will be A LOT faster than anything you can do with normal SQL.
If the file structure is too complex for the import tool to handle, use Perl first to create one or more CSV files that are simple enough.
Comment on Re: DBI: speed up insertions in generating database