ARGV behaviour in getopts std

2010-01-23 Thread Harry Putnam
This is probably blindingly simple but I'm not understanding why @ARGV is not reduced to () (no args)? in this example I'm trying to understand what happens with ARGV in s getops loop with arguments after the getopts Options, or any time there is ARGV, I guess. Why doesn't the `for loop' reduce

Re: ARGV behaviour in getopts std

2010-01-23 Thread Shawn H Corey
Harry Putnam wrote: This is probably blindingly simple but I'm not understanding why @ARGV is not reduced to () (no args)? in this example To Perl, @ARGV is just another array. It has some special features but can be assigned values just like other arrays. You can use it to do tricks, like

Re: ARGV behaviour in getopts std

2010-01-23 Thread Uri Guttman
HP == Harry Putnam rea...@newsguy.com writes: HP print Now lets ditch the rest in a for loop\n; HP for (@ARGV){ change that for to a while. for will create a list of aliases to the array elements passed to it. it doesn't check its length as you seem to think. while will loop until @ARGV is

Re: ARGV behaviour in getopts std

2010-01-23 Thread John W. Krahn
Harry Putnam wrote: This is probably blindingly simple but I'm not understanding why @ARGV is not reduced to () (no args)? in this example [ SNIP ] print Now lets ditch the rest in a for loop\n; for (@ARGV){ my $ditch = shift; perldoc perlsyn [ SNIP ] Foreach Loops [ SNIP ] The

do block and eval block

2010-01-23 Thread 小兰
Hi, what's the difference between do a block and eval a block? sub test { my $bl = shift; eval $bl; # do $bl; } test { print hello\n }; from the code, I see both do and eval work the same. Thanks. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands,

Re: do block and eval block

2010-01-23 Thread Shlomi Fish
Hi Xiaolan! On Sunday 24 Jan 2010 05:37:49 Xiao Lan (小兰) wrote: Hi, what's the difference between do a block and eval a block? sub test { my $bl = shift; eval $bl; # do $bl; } test { print hello\n }; Well, if I run: #!/usr/bin/perl use strict; use warnings; sub test