Did you run it properly? Windows XP, Strawberry Perl 5.12:
C:\>perl opt.pl --library=foo
foo
1
| [reply] [d/l] |
Hi Saved,
Apparently, you didn't pass any argument to your script from the Command Line Interface (CLI), when running it. So, your variable @libfiles is empty, thus, when pass to a scalar variable you get the output "0", when printed.
Consider this:
use warnings;
use strict;
use Data::Printer;
my @gn;
p @gn; # print [] i.e empty
print my $c = () = @gn; ## print 0
So to get the desired result, do this from your CLI:perl script.pl --library=foo,bar,baz then press <ENTER> key. using the following as your perl script.
# your script.pl
use warnings;
use strict;
use Getopt::Long;
my @libfiles;
GetOptions( 'library=s' => \@libfiles );
@libfiles = split( /,/, join( ',', @libfiles ) );
print "@libfiles\n";
my $LstCnt = @libfiles;
print "$LstCnt\n";
Output
foo bar baz
3
So, Getopt::Long is not broken after all.
++ martoz.
Hope this helps
If you tell me, I'll forget.
If you show me, I'll remember.
if you involve me, I'll understand.
--- Author unknown to me
| [reply] [d/l] [select] |
Found using the #!C:\strawberry\perl\bin\perl.exe first line
and running "MLnch.pl -l prd,ift" fails,but no error.
But adding the path to %PATH% , and using:
perl MLnch.pl -l prd,ift works.
| [reply] |
#!C:\strawberry\perl\bin\perl.exe first line and running "MLnch.pl -l prd,ift" fails,but no error..
You probably want to read perlrun and #! and quoting on non-Unix systems especially. You might as well still use #!/usr/bin/perl on window OS. It works for me.
If you tell me, I'll forget.
If you show me, I'll remember.
if you involve me, I'll understand.
--- Author unknown to me
| [reply] [d/l] |