Greetings,
I'm having trouble parsing args from an array. Consider this code:
#!/usr/bin/perl use strict; use warnings; use Data::Dumper; use Getopt::Long 'GetOptionsFromArray'; use feature 'say'; my @args = @ARGV; my %query_params; print "perl args: ".Dumper( \@args ); GetOptionsFromArray ( \@args, \%query_params, 'timestamp' ); print "query_params: ".Dumper( \%query_params ); my $report_type = $args[0]; say "timestamp = $query_params{timestamp}"; say "report type = $report_type"
Results:
./foo.pl class myclass -t 2014-09-08:14:00T-004 perl args: $VAR1 = [ 'class', 'myclass', '-t', '2014-09-08:14:00T-004' ]; query_params: $VAR1 = { 'timestamp' => 1 }; timestamp = 1 report type = class
Why is timestamp's value 1 and not 2014-09-08:14:00T-004?
Neil Watson
watson-wilson.ca
In reply to Help with getopt::long and GetOptionsFromArray by neilwatson
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |