rekha_sri
rekha_sri

Reputation: 2725

Need module to accept the timestamp from command line

I need a module to accept the following timestamp from command line in Perl.

        2010/11/29 09:39:57

I have used the Getopt::Long module to accept the command line options. But it doesn't accept the full timestamp from command line. It is accepting only date value(2010/11/29) not accepting the time value(09:39:57).

If anyone know the module to solve this issue, kindly let me know.

Thanks in advance.

Upvotes: 1

Views: 153

Answers (2)

Eugene Yarmash
Eugene Yarmash

Reputation: 150021

Just put quotes around the timestamp. It should work fine with Getopt::Long

./script.pl -t '2010/11/29 09:39:57'

Upvotes: 3

Leon Timmermans
Leon Timmermans

Reputation: 30235

If you want them to be separate arguments, you could do something like this:

GetOptions('date=s{2}' => \@date);
my ($day, $time) = @date;

Upvotes: 3

Related Questions