There's a few problems with your code:
- Instead of "main::date" try "$date" - you shouldn't need to specify main:: unless you specified a different package.
- You are returning a value (the literal string "main::date"), but thankfully, you're not using it.
- You are splitting on an uninitialised variable ($_), which you would have known if you had warnings turned on. Use $_[0] instead.
- You can change all the splits into one split:
my ($year, $month, $day, $hour, $min, $sec) =
split /[- :]/, $_[0];
- You don't need to modify the global - just return the value you need:
my $date = dateconverter($date_begin);
print $date, "\n";
sub dateconverter {
my @bits = split /[- :]/, $_[0];
return join ".", @bits[0,1,2];
}
-- Dan