seems perfectly plausible thing to try
Sure, you could try to access $foo[42] if only $foo but not @foo is declared. But that won't help you at all: Perl will give you a runtime error with strict enabled. Without strict, perl will just pretend that $foo[42] exists and is undefined.
>perl -MData::Dumper -e 'print Dumper($foo[42])'
$VAR1 = undef;
>perl -MData::Dumper -e 'my $foo="bla"; print Dumper($foo[42])'
$VAR1 = undef;
>perl -MData::Dumper -Mstrict -e 'print Dumper($foo[42])'
Global symbol "@foo" requires explicit package name (did you forget to
+ declare "my @foo"?) at -e line 1.
Execution of -e aborted due to compilation errors.
>perl -MData::Dumper -Mstrict -e 'my $foo="bla"; print Dumper($foo[42]
+)'
Global symbol "@foo" requires explicit package name (did you forget to
+ declare "my @foo"?) at -e line 1.
Execution of -e aborted due to compilation errors.
>
Alexander
--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
|