On Mon, Apr 16, 2001 at 08:37:09PM +0100, Nic LAWRENCE wrote:
> Thought I'd have a go at securing one of my scripts after Ray's question
> about security. When using "strict", I am told the following:
>
> Scalar value @views_keys[$k] better written as $views_keys[$k] at
> ./newremote2.pl line 327.
> Scalar value @_[0] better written as $_[0] at ./newremote2.pl line 342.
> Scalar value @cview_cams[0] better written as $cview_cams[0] at
> ./newremote2.pl line 346.
> Scalar value @_[0] better written as $_[0] at ./newremote2.pl line 359.
>
> I'm curious to know why for example something like @cview_cams[0] would be
> better written as $cview_cams[0]?
The classic example of why it is "better" is:
$cview_cams[0] = <FILE>; # read a line from the file (scalar context)
@cview_cams[0] = <FILE>; # read ALL of the lines from the file
# (list context), put the first line
# into $cview_cams[0], discard all the rest
# of the lines. Probably not what you expect...
> If there's an faq which tells me WHY then
> if someone could point me to that I'd be very happy. ;-)
It makes the difference between "list context" and "scalar context",
as others have already pointed out.
--
Tad McClellan SGML consulting
[EMAIL PROTECTED] Perl programming
Fort Worth, Texas