I have a Perl script to scrub data in CSV files to then be loaded into MySQL Tables. Several of the fields are Date fields that were originally m/d/yyyy - with no leading zeros. I formatted those fields for MySQL using -
$_ = join '-', (split /\//)[2,0,1] for @fields[10,14,24,26];which worked just fine to load the MySQL tables. But now I'm being told these same CSV files may be used in other depts for things like SQL or other programs and they will need leading zeros. I tried using sprintf, but I'm not quite sure how to use it while parsing nor with a scalar variable. This is what I attempted in place of my original line of code, but get "unitialized value" -
$_ = sprintf '%04d-%02d-%02d', split m:/: for @fields[10,14,24,26];What am I doing wrong here? (sorry, parsing and scalars get me confused)
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |