in reply to scalar my vs list my
in thread my $var = ''; vs. use constant VAR => '';
Any statement like 'my $count = @_' can make me feel a little bit dizzy, if only because it seems like anything could happen there (i.e. concatenation with spaces, concatenation without, first element assignment, last element assignment, count of items, index of last item, etc.). Instead, I would rather explicitly specify what is intended as 'my ($count) = scalar (@_);', though rumor would have it that 'scalar' is deprecated.sub Foo { # Arguments: ARRAY <- ARRAY my ($ich, $bin) = @_; # Local variables: SCALAR,SCALAR,... my $x, $y, $z; # Local constants: ARRAY <- ARRAY my ($ein, $berliner) = qw [ jelly donut ]; # Single constant: SCALAR <- SCALAR my $go = 5; }
my $filename = "/path/to/file", $filemode = "immolate", $opmode = "seek", $filetype = "image/gif";
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: scalar my vs list my
by merlyn (Sage) on Apr 27, 2001 at 01:50 UTC | |
by $code or die (Deacon) on Apr 27, 2001 at 01:56 UTC | |
by tadman (Prior) on Apr 27, 2001 at 02:12 UTC |