L
littlepope
Hello all,
I am trying to pass a message to a subroutine and then use Getopt::Long
to break the options down in the message. The problem is that I get
nothing in return. If I put a print statement in I am getting the
message passed to the subroutine but the GetOptions does not seam to
work.
Here is an example of what I am trying to do.
#!/usr/bin/perl -w
use strict;
use Getopt::Long;
my $message ='-r fatal -m "this is a test"';
parse($message);
sub parse
{
my @ARGV=@_;
#print @ARGV;
my $r = ''; # option variable with default value
my $m = ''; # option variable with default value
GetOptions ('r=s' => \$r, 'm=s' => \$m);
print "$r $m\n";
}
When this is run I get a blank return.
Any ideas??
Thanks,
I am trying to pass a message to a subroutine and then use Getopt::Long
to break the options down in the message. The problem is that I get
nothing in return. If I put a print statement in I am getting the
message passed to the subroutine but the GetOptions does not seam to
work.
Here is an example of what I am trying to do.
#!/usr/bin/perl -w
use strict;
use Getopt::Long;
my $message ='-r fatal -m "this is a test"';
parse($message);
sub parse
{
my @ARGV=@_;
#print @ARGV;
my $r = ''; # option variable with default value
my $m = ''; # option variable with default value
GetOptions ('r=s' => \$r, 'm=s' => \$m);
print "$r $m\n";
}
When this is run I get a blank return.
Any ideas??
Thanks,